Repository navigation
fix(adbc): send Rust driver user agent - #426
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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>
2e6b7e0 to
9adf416
Compare
There was a problem hiding this comment.
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.
| } | ||
| fn user_agent_entry(value: OptionValue, key: &str) -> Result<String> { | ||
| let value = string_value(value, key)?; | ||
| if value.chars().any(char::is_control) { |
There was a problem hiding this comment.
🔵 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.
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 recognizeRustADBCDatabricksDriver.Change: The Rust ADBC database boundary now supplies
RustADBCDatabricksDriver/<adbc-version>as the effective HTTP user agent before opening a kernel session. The optionaladbc.databricks.user_agent_entryconnection option appends partner attribution asRustADBCDatabricksDriver/<adbc-version> (<entry>);adbc.spark.user_agent_entryremains a compatibility alias, with the canonical option taking precedence. RawUser-Agentvalues 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 -- --checkcargo clippy --manifest-path adbc/Cargo.toml --all-targets --all-features --locked -- -D warningsUser-Agentheaders, and preservation of unrelated headers.