Skip to content

feat: attribute outbound Databricks requests to AppKit consistently#453

Open
MarioCadenas wants to merge 1 commit into
mainfrom
feat/appkit-attribution-headers
Open

feat: attribute outbound Databricks requests to AppKit consistently#453
MarioCadenas wants to merge 1 commit into
mainfrom
feat/appkit-attribution-headers

Conversation

@MarioCadenas

Copy link
Copy Markdown
Collaborator

What

Make every runtime outbound Databricks request consistently identify itself as AppKit via the SDK's User-Agent stamp (@databricks/appkit/<version>).

Why

Only the service and user WorkspaceClients passed getClientOptions(), so only they carried the AppKit User-Agent. The other runtime paths were unattributed:

  • Cache client (cache/index.ts) used bare new WorkspaceClient({}) and sent unknown/0.0.0.
  • Files upload and MCP connectors use raw fetch that bypasses the SDK apiClient, so they carried no AppKit User-Agent at all.

The @databricks/sdk-experimental SDK has no default-headers hook (ClientOptions exposes only agent/product/productVersion/userAgentExtra, and apiClient.request() overwrites User-Agent per call), so User-Agent is the correct lever.

Changes

  • New packages/appkit/src/context/client-options.ts: extracts the previously-private getClientOptions() and adds APPKIT_USER_AGENT for raw-fetch sites that have no apiClient.
  • service-context.ts: imports getClientOptions from the new module.
  • cache/index.ts: passes getClientOptions() to the WorkspaceClient.
  • connectors/files/client.ts: upload PUT now sets User-Agent from client.apiClient.userAgent().
  • connectors/mcp/client.ts: both fetches now carry User-Agent: APPKIT_USER_AGENT.

Scope

Attribution only -- no new X- header, no DATABRICKS_APP_NAME/per-app identity, no SDK monkeypatching. Out of scope: the standalone @databricks/lakebase package, build-time type-generators, and Postgres wire traffic (cannot carry HTTP headers).

Verification

  • Extended MCP + files connector unit tests assert the User-Agent is attached (70 tests pass).
  • pnpm -r typecheck, Biome on changed files, pnpm build, and pnpm docs:build all clean.
  • Sanity-checked locally with a temporary debug log in the dev-playground: outbound calls logged User-Agent: @databricks/appkit/0.41.5 databricks-sdk-js/0.17.0 nodejs/24 os/darwin auth/undefined mode/dev (no SP token configured locally; mode/dev from dev mode). The debug log is not part of this PR.

Only the service and user WorkspaceClients carried the AppKit User-Agent
(@databricks/appkit/<version>). The cache client sent unknown/0.0.0, and
the two raw-fetch sites (files upload, MCP connector) sent no AppKit
User-Agent at all, since they bypass the SDK apiClient.

Extract getClientOptions() into a shared context/client-options module
(adding APPKIT_USER_AGENT for fetch sites with no apiClient), pass it to
the cache client, and stamp the User-Agent on the files upload fetch (via
apiClient.userAgent()) and both MCP fetches.

Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
@MarioCadenas MarioCadenas requested a review from a team as a code owner June 19, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant