Repository navigation
Conversation
The kernel backend (use_kernel=True) ignored the Thrift-style _port and _connection_uri overrides. Resolve both connector-side onto the kernel's single host and http_path, with the Thrift rules: - _port (1..65535; 0 or None mean the default) folds into server_hostname as host:port. The default 443 adds nothing, IPv6 literals are bracketed, and an embedded port equal to _port is accepted. An empty server_hostname with _port raises ValueError. - _connection_uri (http(s)://host[:port]/path?query) replaces host, port, path and query, and wins over _port. Scheme-less, non-http(s), path-less and credential-bearing URIs raise ValueError. URI-only use works. - With OAuth (U2M, Azure service principal, JWT key file, or M2M client id and secret), a _connection_uri whose origin differs from https://server_hostname raises before a kernel session opens. PAT is not affected. A non-default _port with OAuth is not guarded: the token exchange goes to the same host:port, which is documented. - The SPOG x-databricks-org-id header follows the resolved path. Tests cover the resolver tables, the OAuth origin guard, the SPOG re-derivation, and a real-wheel loopback dial proving the kernel reaches the requested port over TLS for _port and for _connection_uri. Co-authored-by: Isaac <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
The helper returned Optional[str] for the resolved path, but KernelDatabricksClient takes a str, so mypy fails in check-types on every supported Python. Session.__init__ already types http_path as str, so this is an annotation-only change with no runtime effect. Co-authored-by: Isaac <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 2 Low
Looks good: two low concerns. Resolver, OAuth origin guard and SPOG re-derivation match Thrift's precedence and have thorough table tests. Nit: a few new lines (the Conflicting-ports f-string, the _split_host and _uri_host_and_path docstrings) exceed the 100-char limit in CONTRIBUTING.md.
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 2 Low
Looks good, with 1 low concern. The resolver, the OAuth origin guard and the SPOG re-derivation match the auth bridge's routing and are well covered by tests. Nit: a few new lines go past the 100-char limit (the Conflicting ports f-string and the _split_host/_uri_host_and_path docstrings), and the AC-P4 ticket reference in the docstring.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
A kernel connection without _port or _connection_uri again passes server_hostname through unchanged, so odd hosts no longer raise on the default path. The OAuth origin guard now skips connections the kernel auth bridge routes to PAT: an access_token with no JWT or client-secret M2M credentials, even when auth_type is databricks-oauth. azure-sp-m2m and M2M/JWT stay guarded. Co-authored-by: Isaac <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with 1 low concern. The resolver, the OAuth predicate (which matches the auth bridge's routing) and the SPOG re-derivation all check out. Nits: session.py:135 and the _split_host/_uri_host_and_path docstrings go past the 100-char limit, and test_session.py imports databricks.sql twice.
Wraps the origin-guard condition to the repo's black line length (check-linting). The guard no longer treats a custom credentials_provider as OAuth: the kernel auth bridge rejects that provider with NotSupportedError, so no OAuth origin is involved. Co-authored-by: Isaac <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
Remove _is_bare_ipv6 and the ipaddress import. Bare IPv6 hosts such as ::1 never worked on the kernel path: the kernel prepends https:// and its URL parser rejects an unbracketed IPv6 literal. IPv6 literals must be bracketed ([::1]).
With _port set, urlsplit reads everything after the first colon of a bare IPv6 literal as the port. That text always contains another colon, so the integer parse fails and the existing "malformed IPv6 literal or port" ValueError is raised before any request. This includes _port=443. Without _port the host still passes through unchanged, as on main.
Tests: the ("::1", 8443) -> "[::1]:8443" row is removed. ::1 with _port 8443 or 443, and 2001:db8::1 with _port 8443, are now in the reject table.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Cathleen Yan <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
✅ No issues identified.
🔀 1 finding considered and dismissed by the judge
- 🟡 Medium
src/databricks/sql/session.py:240— An access_token combined with identity_federation_client_id bypasses the origin guard when its issuer matches server_hostname, although the bridge forwards that
Judge's evidence:if routed_to_pat or not oauth:
mypy (check-types) rejected passing the Optional access_token to _is_foreign_jwt, because bool(access_token) does not narrow its type. Use `access_token and _is_foreign_jwt(...)` inside bool(), which narrows it. The behavior is the same; the session tests pass. Co-authored-by: Isaac <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, no blocking issues. The host/port/URI resolution, the OAuth-origin guard (which follows the auth_bridge.py routing order) and the SPOG re-derivation all check out. Nit: no test covers a caller-set x-databricks-org-id combined with _connection_uri, and test_resolved_kernel_host_and_path_reach_kernel_client never closes its connection.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
_redact kept everything before the first "://" as the scheme. In a scheme-less _connection_uri such as "h.io/sql/x?token=secret&redirect=https://example.com", that prefix is the path and query, so the error message echoed token=secret. The prefix is now kept only when it is http or https; otherwise it is shown as <redacted>. Two regression rows in test_invalid_connection_uri_message_omits_credentials fail without this change. Co-authored-by: Isaac <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Medium · 1 Nit
Looks good, no blocking issues. I checked the host/port/URI resolution, redaction, the SPOG header re-derivation, and the OAuth origin guard's PAT-routing logic against auth_bridge.kernel_auth_kwargs (azure-sp-m2m, then JWT, then M2M, then PAT, then U2M), and they are consistent. Thrift passthrough is unchanged and covered by tests.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- 🟡 Medium — An access_token paired with identity_federation_client_id bypasses the origin guard as PAT, although the bridge forwards that selector for mandatory token exchange, allowing _connection_uri to redirect that exchange to another origin. Treat an explicit federation client ID as exchange-bearing auth, exclude it from the PAT exemption, and add a mismatched-origin regression test. (Found by GPT-6.1 Sol · the judge couldn't confirm it)
- ⚪ Nit — The test opens a kernel connection and never closes it, unlike test_spog_org_id_follows_resolved_path. Append .close() to the connect() call. (Found by Claude Opus 5.5 · confirmed by the judge)
…is set With identity_federation_client_id, the kernel bridge forwards the access_token for mandatory workload-identity token exchange at the connection host. _check_oauth_origin routed any access_token that wasn't a foreign-issuer JWT to the PAT exemption, so a mismatched _connection_uri origin could receive that exchange, where Thrift exchanges at server_hostname. Such a token now counts as OAuth for the origin check, so a mismatched origin raises before any request. A plain PAT without a federation client id is unaffected. Also close the connection in test_resolved_kernel_host_and_path_reach_kernel_client, and describe the exchanged-token rule in CONNECTION_PARAMETERS.md. Co-authored-by: Isaac <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
|
Both findings from the latest review are addressed in 973b4e2.
The session tests (200), kernel client tests (282), mypy on Automated reply from the driver feature factory (Isaac). Not reviewed by a human. |
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
✅ No issues identified.
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/databricks/sql/session.py:259—_check_oauth_originreuses_split_host, which raises when_portis used with a malformed host. So OAuth plus a valid_connection_urifails with "malform
Judge's evidence:f"Invalid server_hostname {_redact(host)!r}: malformed IPv6 literal or port"
An explicit _port=443 adds nothing to the kernel host, but it still ran the checks for a folded port, so a host that main sent through as-is was now rejected: a path or query (`h.io/x`, `h.io?x=1`), a bare IPv6 literal (`::1`), userinfo (`user:pw@h`), or an empty host. 443 now returns the host unchanged before those checks, as on main and as the Node driver does. A non-default _port is unchanged. Co-authored-by: Isaac <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 High · 1 Low
Looks good, with 1 low concern. Port/URI resolution, the OAuth origin guard and the SPOG re-derivation match the auth bridge's routing order and have thorough tests. Nit: the CHANGELOG says "as on main", which is internal wording that shouldn't appear in release notes.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- 🟠 High — Disputed by the cross-check judge (it quotes
return not is_same_host(issuer, normalize_host_with_protocol(server_hostname))); a human should decide. Original finding: A JWT issued by h.io bypasses the OAuth origin guard when_connection_uritargets another host, because this comparison uses the original hostname even though the kernel receives the overridden host and token together for federation. Classify exchange eligibility against the resolved kernel host as well, and add a same-issuer-JWT/cross-origin regression test. (Found by GPT-6.1 Sol · disputed by the judge)
…n mismatch With OAuth and _connection_uri, the origin guard parsed server_hostname with the _port parser, so a host such as '::1', 'h.io:' or 'user:[email protected]' raised 'malformed IPv6 literal or port' even though no _port was set. The guard now treats a server_hostname it cannot parse as an origin that cannot match, and raises its own origin-mismatch error. The changelog entry no longer says 'as on main'. Co-authored-by: Isaac <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 High
Looks good, no blocking issues. I traced the resolver, the OAuth origin guard and the SPOG header re-derivation against auth_bridge.kernel_auth_kwargs. The guard's routing predicates (M2M, JWT, azure-sp-m2m, PAT, U2M) match the bridge, and Thrift is unchanged.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- 🟠 High — Disputed by the cross-check judge (it quotes
foreign_jwt = bool(access_token and _is_foreign_jwt(access_token, server_hostname))); a human should decide. Original finding: A JWT issued byserver_hostnamebypasses this guard when_connection_uripoints elsewhere, although it becomes foreign to the resolved kernel host and eligible for token exchange there. Classify JWT exchange against both the original and resolved hosts, and add a same-original-issuer/different-URI regression test. (Found by GPT-6.1 Sol · disputed by the judge)
The kernel now folds _port into the connection host (databricks-sql-kernel #505), so the driver no longer rewrites server_hostname. The session passes server_hostname through unchanged and the parsed _port as the binding's port= kwarg. The driver keeps what is driver-specific: _port parsing (falsy means the default, invalid values raise ValueError), _connection_uri resolution into host, port and path, the OAuth origin guard, and redaction of its own error messages. port= is sent only when a non-default port applies, so the default path sends the same kwargs as before. A wheel without the kwarg raises NotSupportedError instead of silently connecting to port 443. Removed the driver-side folding rules (embedded-port-wins and its warning, path/userinfo/IPv6 checks, _split_host). Kernel InvalidArgument errors now surface as ProgrammingError rather than ValueError. KERNEL_REV is pinned to 22ae6ec250837b38d0e3dc720310d4dcfb81fa98 so the kernel-e2e workflow builds the kernel with port support. This PR needs a kernel release that includes databricks-sql-kernel#505. Signed-off-by: Cathleen Yan <[email protected]> Co-authored-by: Isaac <[email protected]>
Resolved two conflicts. CHANGELOG.md: Unreleased keeps the port entry plus main's new fetch speed-up entry; the other entries were released in 4.10.0. KERNEL_REV keeps 22ae6ec (the kernel port PR head), which already contains main's 5c3a909. Signed-off-by: Cathleen Yan <[email protected]> Co-authored-by: Isaac <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 High · 1 Medium · 2 Low
Mostly solid. I have 1 medium and 1 low concern, both about the tests. The driver resolves the port, URI and OAuth origin carefully and the coverage is broad. The KERNEL_REV and dependency-floor bumps listed under "Before merge" are still pending.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- 🟡 Medium — A JWT issued by the original server is classified as PAT when
_connection_uriselects another host, bypassing the origin guard even though the kernel's host-relative exchange decision uses that new destination. Include the resolved kernel host when determining whether the token requires exchange, and add a regression with issuerhttps://h.io/oidcand URIhttps://other.io/sql/x. (Found by GPT-6.1 Sol · the judge couldn't confirm it)
| geospatial_kwargs = _kernel_geospatial_kwargs( | ||
| self._enable_geospatial_support | ||
| ) | ||
| port_kwargs = _kernel_port_kwargs(self._port) |
There was a problem hiding this comment.
🟠 High — The dependency floor stays at ^1.5.0 although the feature needs a kernel release containing kernel#505. The driver raises a clear NotSupportedError on older wheels, but the published-wheel realkernel CI tier cannot pass until the floor and lockfile move. Bump the floor and lockfile once that kernel is released.
🔀 Found by GPT-6.1 Sol · confirmed by the judge
The OAuth origin guard judged a JWT's issuer only against server_hostname. The kernel judges it against its connection host, so a token issued by server_hostname with a _connection_uri on another host was treated as a PAT here but exchanged by the kernel at that other host. A token foreign to either host now counts as exchanged, so the mismatched origin is rejected. Added the h.io issuer + other.io URI case. Tests: - The loopback realkernel tests skip when the installed wheel has no port kwarg, and re-raise NotSupportedError instead of swallowing it and timing out. They pass on a wheel built from the kernel PR and skip on the published 1.4.0 wheel. - The old-wheel port test uses a fixed-signature fake Session, so the real signature introspection decides, as in the geospatial test. Signed-off-by: Cathleen Yan <[email protected]> Co-authored-by: Isaac <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 2 Low
Looks good, with 1 low concern. Before merge, KERNEL_REV still has to point at the merged kernel commit, and the databricks-sql-kernel floor and lockfile need a released wheel that has the port kwarg. The PR description already lists both.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
| """ | ||
| if not port or port == 443: | ||
| return {} | ||
| if not _kernel_session_accepts_kwarg("port"): |
There was a problem hiding this comment.
🔵 Low — The dependency floor is still ^1.5.0, so a released install without the port kwarg raises NotSupportedError for a non-default _port. The failure is explicit, not silent. Once the kernel release with #505 is published, raise the floor and update the lockfile.
🔀 Found by GPT-6.1 Sol · confirmed by the judge
urlsplit reads "https://h.io:/sql/x" as having no port, so the URI passed validation and "https://h.io:" went to the kernel. An authority that ends in ":" is now rejected as malformed, like port 0. Covered for a host name and a bracketed IPv6 literal. Signed-off-by: Cathleen Yan <[email protected]> Co-authored-by: Isaac <[email protected]>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 High
Looks good, no blocking issues. The OAuth origin guard's classification follows auth_bridge routing order. Before merge, as the description says: move KERNEL_REV to the merged kernel commit and raise the databricks-sql-kernel floor and lockfile to a released wheel. Nit: client.py docstring says https:// but http:// is also accepted.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- 🟠 High — Disputed by the cross-check judge (it quotes
if not _kernel_session_accepts_kwarg("port"): raise NotSupportedError(); a human should decide. Original finding: The dependency floor still permits—and the lockfile selects—kernel 1.5.0, so a supported installation raises NotSupportedError for the newly advertised non-default_portfeature; updating KERNEL_REV does not update the shipped wheel dependency. Before merging, raise the dependency floor and regenerate the lockfile against a released kernel containing the port binding. (Found by GPT-6.1 Sol · disputed by the judge)
Summary
On the kernel backend (
use_kernel=True),_portand_connection_uriare now honored. Before this PR the kernel path ignored both. Thrift is unchanged.The kernel now applies the port (databricks/databricks-sql-kernel#505). The driver passes
server_hostnamethrough unchanged and sends_portas the binding'sport=kwarg, so the driver no longer folds the host itself.Behavior
host:port, with a bare IPv6 host bracketed;_portmeans the default, as on Thrift; an invalid_portraisesValueError;port=is sent only for a non-default port, so the default path sends the same kwargs as before;portkwarg raisesNotSupportedErrorinstead of silently connecting to 443._connection_uri(http(s)://host[:port]/path?query) sets the host (with any port in it) and the path, and wins over_port. A URI-only connection works._connection_uriwhose origin differs fromserver_hostnameraises before any request. PAT is unaffected.ProgrammingError(the kernel'sInvalidArgument) rather thanValueError. Noted in the CHANGELOG.Before merge
KERNEL_REVpoints at the kernel PR's head (22ae6ec). Move it to the merged kernel commit.databricks-sql-kerneldependency floor and lockfile to a release that includes the kernel change. Until then the published-wheel CI tier skips the two loopback port tests.Testing
test_session.py(160) andtest_kernel_client.py(289) pass. black is clean.Note
This overlaps databricks-sql-python#915, another engineer's PR that changes the same function. Only one of the two should merge.
Related PRs: https://github.com/databricks/databricks-sql-kernel/pull/505, databricks/databricks-sql-nodejs#636, databricks/databricks-sql-go#581, https://github.com/databricks/databricks-driver-test/pull/2188
This pull request and its description were written by Isaac.