Repository navigation
fix(http): overwrite base User-Agent with caller UA for accurate query-source attribution - #151
Merged
Merged
Conversation
vikrantpuppala
had a problem deploying
to
azure-prod
June 9, 2026 11:12 — with
GitHub Actions
Failure
…y-source attribution The kernel's base User-Agent is `DatabricksJDBCDriverOSS/<ver>` (a JDBC masquerade so the SEA server enables the INLINE_OR_EXTERNAL_LINKS result disposition, gated on a `startsWith` prefix match of the `databricks.sqlexecapi.known_driver_prefixes` flag). A caller-supplied `User-Agent` (the connector's composed `PyDatabricksSqlConnector/x (entry)`) was previously *appended* to that base. The appended shape (`DatabricksJDBCDriverOSS/x PyDatabricksSqlConnector/y (entry)`) matched none of the gateway's `QuerySourceHelper.parseUserAgent` patterns and was recorded as driver="other", dropping the connector's identity and any partner `user_agent_entry` from attribution. Switch to *replacing* the base UA with the caller UA verbatim, so the SEA server sees an accurate driver identity (e.g. matches the anchored `pythonConnectorPattern`). When no caller UA is supplied, the base stays `DatabricksJDBCDriverOSS/...` so unattributed requests still pass the gate. PRECONDITION: the caller UA's prefix must be allow-listed in `databricks.sqlexecapi.known_driver_prefixes`, or external INLINE_OR_EXTERNAL_LINKS requests are rejected (HTTP 400 / Thrift redirect). `PyDatabricksSqlConnector` is being added to that flag; this kernel change must land *after* that flag rollout is ramped. Also hardens the 1 KiB UA truncation to cut on a UTF-8 char boundary (the prior byte slice could panic mid-codepoint), and adds unit tests for replace / empty-keeps-base / no-UA-keeps-base / oversized-truncation. Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala
force-pushed
the
feat/kernel-ua-overwrite
branch
from
June 9, 2026 11:35
279db88 to
47842b7
Compare
vikrantpuppala
had a problem deploying
to
azure-prod
June 9, 2026 11:35 — with
GitHub Actions
Failure
vikrantpuppala
enabled auto-merge
June 9, 2026 11:35
gopalldb
approved these changes
Jun 9, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a wrapper (the Python connector) supplies a
User-Agentvia a custom header, the kernel now replaces its base UA with the caller's UA verbatim, instead of appending it.DatabricksJDBCDriverOSS/<ver> PyDatabricksSqlConnector/<ver> (entry)PyDatabricksSqlConnector/<ver> (entry)When no caller UA is supplied, the base UA stays
DatabricksJDBCDriverOSS/<ver>(unchanged).Why
The base UA is a JDBC masquerade — the SEA server enables the
INLINE_OR_EXTERNAL_LINKSresult disposition only for "known drivers", gated on astartsWithprefix match against thedatabricks.sqlexecapi.known_driver_prefixesSAFE flag (defaultDatabricksJDBCDriverOSS).The appended shape matched none of the gateway's
QuerySourceHelper.parseUserAgentpatterns, so kernel-originated queries were attributed asdriver="other", and the connector's identity + any partneruser_agent_entrywere dropped from query-source attribution entirely.Overwriting with the clean caller UA lets the gateway's anchored
pythonConnectorPattern(^(?i)(PyDatabricksSqlConnector)/...$) match correctly, restoring accurate attribution.Rollout dependency — MERGE ORDER MATTERS
This is only safe once
PyDatabricksSqlConnectoris allow-listed indatabricks.sqlexecapi.known_driver_prefixes.Until that flag is ramped where kernel traffic runs, external
use_kernelrequests asking forINLINE_OR_EXTERNAL_LINKSwould fail the known-driver prefix check, returningInlineOrExternalLinksNotSupported(HTTP 400) / Thrift redirect, breaking parallel result fetching.Required order: flag rollout (allowlist
PyDatabricksSqlConnector, ramped) -> then this kernel change.Also in this PR
custom_headersdoc comments (struct field +HttpConfig) to document the replace semantics and the allow-list precondition.Test
cargo test --lib client::http::tests-> 60 passed.cargo clippy --lib --testsclean.