From 35bc28ab903018eddab48ec2b668da6484690f4c Mon Sep 17 00:00:00 2001 From: Hector Castejon Diaz Date: Tue, 21 Apr 2026 10:20:26 +0000 Subject: [PATCH] Add X-Databricks-Org-Id header to SharesExtImpl.list() for SPOG Hand-written extension methods in the mixins bypass the generated per-call header logic. On SPOG hosts, requests without X-Databricks-Org-Id are rejected by the proxy with: Error: Unable to load OAuth Config (400 UNKNOWN) Generated service methods (e.g. WorkspaceImpl.export/importContent, SharesImpl.* generated endpoints) already set this header when cfg.workspaceId is populated. This change brings the hand-written SharesExtImpl.list() in line. Ports databricks/databricks-sdk-go#1635. The other two fixes from databricks/databricks-sdk-py#1397 do not apply to Java: - WorkspaceExt.upload/download: no hand-written Java equivalent; the generated WorkspaceImpl.export()/importContent() already set the header on every call. - WorkspaceClient.get_workspace_id() short-circuit: Java WorkspaceClient has no equivalent method. Co-authored-by: Isaac --- NEXT_CHANGELOG.md | 1 + .../java/com/databricks/sdk/service/sharing/SharesExtImpl.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index c1d2c483c..a774c1991 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -6,6 +6,7 @@ * Added automatic detection of AI coding agents (Amp, Antigravity, Augment, Claude Code, Cline, Codex, Copilot CLI, Copilot VS Code, Cursor, Gemini CLI, Goose, Kiro, OpenClaw, OpenCode, Windsurf) in the user-agent string. The SDK now appends `agent/` to HTTP request headers when running inside a known AI agent environment. Also honors the `AGENT=` standard: when `AGENT` is set to a known product name the SDK reports that product, and when set to an unrecognized non-empty value the SDK reports `agent/unknown`. Environment variables set to the empty string (e.g. `CLAUDECODE=""`) now count as "set" for presence-only matchers, matching `databricks-sdk-go` semantics; previously they were treated as unset. Explicit agent env vars (e.g. `CLAUDECODE`, `GOOSE_TERMINAL`) always take precedence over the generic `AGENT=` signal. When multiple agent env vars are present (e.g. a Cursor CLI subagent invoked from Claude Code), the user-agent reports `agent/multiple`. ### Bug Fixes +* Add `X-Databricks-Org-Id` header to `SharesExtImpl.list()` for SPOG host compatibility. Without this header, calls to the hand-written extension were rejected by the SPOG proxy with `Unable to load OAuth Config (400 UNKNOWN)`. Mirrors [databricks/databricks-sdk-go#1635](https://github.com/databricks/databricks-sdk-go/pull/1635). ### Security Vulnerabilities diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/sharing/SharesExtImpl.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/sharing/SharesExtImpl.java index a1ab2be87..386f883e9 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/sharing/SharesExtImpl.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/sharing/SharesExtImpl.java @@ -19,6 +19,9 @@ public ListSharesResponse list(ListSharesRequest request) { Request req = new Request("GET", path); ApiClient.setQuery(req, request); req.withHeader("Accept", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Org-Id", apiClient.workspaceId()); + } return apiClient.execute(req, ListSharesResponse.class); } catch (IOException e) { throw new DatabricksException("IO error: " + e.getMessage(), e);