Skip to content

fix(adbc): send Rust driver user agent - #426

Merged
rahuls-db merged 4 commits into
mainfrom
rahul-singhal_data/rahul-singhal/rust-adbc-user-agent
Nov 9, 2026
Merged

rahuls-db merged 4 commits into
mainfrom
rahul-singhal_data/rahul-singhal/rust-adbc-user-agent

Conversation

@rahuls-db

@rahuls-db rahuls-db commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

What did you change, and why?

Why: Rust ADBC currently inherits the shared kernel DatabricksSQLKernel/<version> user agent, so server-side query attribution cannot distinguish Rust ADBC traffic. The server allowlists now recognize RustADBCDatabricksDriver.

Change: The Rust ADBC database boundary now supplies RustADBCDatabricksDriver/<adbc-version> as the effective HTTP user agent before opening a kernel session. The optional adbc.databricks.user_agent_entry connection option appends partner attribution as RustADBCDatabricksDriver/<adbc-version> (<entry>); adbc.spark.user_agent_entry remains a compatibility alias, with the canonical option taking precedence. Raw User-Agent values in generic custom headers are rejected rather than silently discarded. This applies to session creation, feature-flag fetches, statement execution, and result fetching while leaving the shared kernel's default identity unchanged for other consumers. Caller-provided non-user-agent headers are preserved.

How do you know it works?

Testing:

  • cargo +stable fmt --all -- --check
  • cargo clippy --manifest-path adbc/Cargo.toml --all-targets --all-features --locked -- -D warnings
  • Native Rust ADBC suite: 94 passed.
  • Rust ADBC suite with the optional C ABI enabled: 96 passed.
  • Focused unit tests verify the exact default and partner-attributed wire values, canonical-over-alias precedence, public option round-tripping, case-insensitive rejection of raw User-Agent headers, and preservation of unrelated headers.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Medium

The change is small and correct for the default case, with one medium concern: a caller's User-Agent set through adbc.databricks.http.headers is accepted, then silently dropped. It should be appended to the driver's UA or rejected up front. Nit: the test rebuilds the expected string by hand; it could call driver_user_agent(), though keeping the literal format does pin down the exact shape.

Comment thread adbc/src/database.rs Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 2 Low

The PR looks correct: the kernel's existing User-Agent fold (src/client/http.rs:425-459) overrides the DatabricksSQLKernel base, and that base stays unchanged for other consumers. I found two low-severity issues: the entry value isn't validated, and no wire-level test covers the ADBC user agent.

Comment thread adbc/src/database.rs Resolved
Comment thread adbc/src/database.rs Resolved
Signed-off-by: Rahul Singhal <rahul.singhal@databricks.com>
Signed-off-by: Rahul Singhal <rahul.singhal@databricks.com>
Signed-off-by: Rahul Singhal <rahul.singhal@databricks.com>
Signed-off-by: Rahul Singhal <rahul.singhal@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good, with one low-severity concern: the new option validates input only partly, so some bad values fail later at new_connection() instead of when the option is set. The User-Agent override fits the kernel's existing handling, where a caller-supplied User-Agent in custom headers is pulled out and replaces the default (src/client/http.rs:425-459). Rejecting raw User-Agent headers up front also stops users from overriding the driver's identity.

Comment thread adbc/src/config.rs
}
fn user_agent_entry(value: OptionValue, key: &str) -> Result<String> {
let value = string_value(value, key)?;
if value.chars().any(char::is_control) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — user_agent_entry only rejects char::is_control. Non-ASCII input like partnér or an emoji still passes set_option, but it ends up in config.user_agent and goes to reqwest's ClientBuilder::user_agent, which only accepts visible ASCII. So the bad value is accepted and echoed back by get_option, and the failure only shows up later in new_connection(), as an HTTP client build error that doesn't name adbc.databricks.user_agent_entry. Since this PR already validates the option up front, it should reject anything outside visible ASCII (!(c == ' ' || c.is_ascii_graphic())). That way the user gets InvalidArguments naming the key at set time. Also worth adding a test case with a non-ASCII value.

@rahuls-db
rahuls-db added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 1d3f372 Nov 9, 2026
26 of 28 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — 9adf416f Deployed Nov 9, 2026 by oss-reviewer-bot[bot] via followup #2227
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants