Repository navigation
feat(kernel): support credentials_provider on kernel connections - #1086
Conversation
On use_kernel=True the connector now builds the same provider chain as Thrift (TokenFederationProvider wrapping ExternalAuthProvider) and passes it to the kernel's external auth as a per-request header provider, so header caching, token federation with identity_federation_client_id and exchange fallback behave as on Thrift. credentials_provider takes precedence over access_token and every auth_type (azure-sp-m2m included), as on Thrift; paired with oauth_client_secret or oauth_jwt_key_file it is rejected as ambiguous before any flow is chosen. The connector keeps its HTTP client for these connections so the federation exchange works, and an older kernel wheel without header_provider raises NotSupportedError. KERNEL_REV pins the kernel commit that adds the header provider. Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
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 one low test-coverage concern. Routing, precedence, the Session provider chain, the Reyden recovery path and keeping the http_client all match Thrift. A live token-federation exchange is still untested, as the PR says.
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
raise NotSupportedError( "credentials_provider requires a newer databricks-sql-kernel " "wheel that accepts a header provider."); a human should decide. Original finding: The declared kernel dependency still permits 1.5.0, which lacksheader_provider, so a supported installation can reject this new feature and provider-based Reyden recovery despite the source revision bump. Before merging, complete the stated release dependency by raising the kernel floor to the first supporting release and updatingpoetry.lockandKERNEL_REV. (Found by GPT-6.1 Sol · disputed by the judge)
|
On the review-bot High about the Automated reply from the driver feature factory (Isaac). Not reviewed by a human. |
Resolves the KERNEL_REV conflict with the SOCKS docs change by pinning kernel 159a2ff (databricks/databricks-sql-kernel#527), which includes both SOCKS and the external header provider. Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
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. Routing, precedence, the ambiguity guards, the old-wheel gating and Reyden recovery all match the Thrift chain. One gap: no connect()-level test checks that a kernel connection with credentials_provider builds the HTTP client the token exchange needs.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge — see the findings below.
🔀 1 finding considered and dismissed by the judge
- 🟡 Medium
src/databricks/sql/backend/kernel/client.py:483— The locked kernel remains 1.5.0, which lacks header-provider support, so installing the currently packaged dependency still rejects the newly supported credenti
Judge's evidence:raise NotSupportedError( "credentials_provider requires a newer databricks-sql-kernel " "wheel that accepts a header pro…
The old-kernel test's fake Session lacked enable_geospatial_support, so the geospatial guard raised a NotSupportedError with the same "newer databricks-sql-kernel" text before the header_provider guard could be checked. Removing the header_provider guard left the test passing. Add the kwarg to the fake and match on the "credentials_provider requires a newer databricks-sql-kernel" message. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
|
Release-gated and expected; no change in this round. Review 6161786736 (the disputed High) and review 6162310109 (the dismissed Medium on the same pin) both raise the kernel floor, Review 6162310109's Low (connect-level HTTP-client test) is the same item as the inline comment: not pushed in this round as a test-coverage Low. The inline Low from the same review ( 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).
Verdict: 2 Low · 1 Nit
Looks good: 1 medium and 1 low concern. The kernel routing, the old-wheel gate, and the per-connection lock around the shared federation state are sound and match Thrift. Shipping this still needs a released kernel wheel and a raised dependency floor, as the PR description says.
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
- ⚪ Nit — Kernel connections that pass both
credentials_providerandaccess_tokenorauth_type='azure-sp-m2m'now use the provider, which changes behavior, and the changelog doesn't say so. Add a note about the new precedence to the entry. (Found by Claude Opus 5.5 · confirmed by the judge)
|
Acknowledged as a changelog Nit; no code change under the bot-loop rule. Accepted decision D8 intentionally makes kernel precedence match Thrift ( Automated reply from the driver feature factory (Isaac). Not reviewed by a human. |
aakash-saravanan-db
left a comment
There was a problem hiding this comment.
Approving. Routing credentials_provider through the same TokenFederationProvider(ExternalAuthProvider(...)) chain as Thrift, with Thrift's precedence, looks right. I left two optional inline notes.
One description fix: the testing table lists "Real federation exchange, GitHub OIDC (driver-test AUTH-033 in CI)" as passing. AUTH-033 isn't on databricks-driver-test main yet, and databricks/databricks-driver-test#2423 shows no CI checks at its current head, so I couldn't find that run. Could you link it, or mark the row as pending #2423?
Replace the sleep-based overlap test with the event-based version from review: the first add_headers call blocks on a release event, so the second call provably cannot enter while the first is in flight — the test now fails deterministically without the serialization lock instead of only almost-always. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
|
Thanks @aakash-saravanan-db. All three points addressed:
This comment was written by Isaac. |
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 one low-severity test gap. Routing, the precedence and ambiguity checks, and the gate for older kernel wheels all match Thrift's get_auth_provider. Merge is still blocked on a released kernel wheel plus the KERNEL_REV and dependency-floor bumps, which the PR description already lists.
Add test_kernel_credentials_provider_keeps_python_http_client: on use_kernel=True with a credentials_provider the connector still builds a UnifiedHttpClient and hands it to the session, the federation- wrapped provider chain and the kernel, as on Thrift. Verified the test fails with the gate removed (TokenFederationProvider raises on http_client=None). The no-provider control case is covered by test_kernel_http_client_lifecycle[explicit]. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
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.
🔀 2 findings considered and dismissed by the judge
- 🔵 Low
src/databricks/sql/backend/kernel/auth_bridge.py:176— The lock is held for the wholeadd_headerscall, which includes the user's header factory and any federation token exchange. A provider whose headers aren't c
Judge's evidence:The kernel calls it on every authenticated request, possibly from several kernel threads at once, so calls are serialize… - 🟡 Medium
src/databricks/sql/backend/kernel/client.py:483— The dependency floor still permits kernel 1.5.0 and the lockfile selects it, so locked installations reject every connection using the newly supported provider
Judge's evidence:raise NotSupportedError( "credentials_provider requires a newer databricks-sql-kernel " "wheel that accepts a header pro…
KERNEL_REV moves from the #527 branch head 159a2ff to the commit merged into kernel main, 6d6c1e4. That picks up the external-auth conflict guard (Session rejects credential/OAuth/JWT/Azure/ federation/token-cache kwargs alongside auth_type="external"), async-only external auth in the kernel core, reserved SEA per-request routing headers, and the Volume and LZ4 config changes that landed on kernel main in between. The connector passes only auth_type="external" plus header_provider on the provider path, so no connector change is needed. Verified against the wheel built from 6d6c1e4: the full unit suite (1465 passed), the real-kernel session (5) and async-reader (6) suites, black and mypy. Also drops the kernel-release sentence from the changelog entry; the kernel floor and lockfile move at the joint kernel and driver release, not here. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
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 one low concern. Routing works end to end: session.py builds the provider chain, auth_options forwards the provider, the bridge gives it precedence, the old-wheel check is in place, and Reyden recovery reuses the Thrift http_client.
Summary
credentials_providernow works withuse_kernel=True. Until now, the kernel path raisedNotSupportedError. Whenaccess_tokenorauth_typewas also set, it silently ignored the provider. The kernel now calls the same provider chain the Thrift path builds, so caching, extra headers,identity_federation_client_id, the token exchange and its fallback all behave as they do on Thrift.What changes
credentials_provideris wrapped exactly as on Thrift (TokenFederationProvider(ExternalAuthProvider(...))) and passed to the kernel's per-request header provider.credentials_providertakes precedence overaccess_tokenand everyauth_type, as on Thrift. Combining it withoauth_client_secretoroauth_jwt_key_fileraises an ambiguity error instead of picking one.use_kernel=TrueraisesNotSupportedErrorand asks for a newer wheel.CONNECTION_PARAMETERS.mdmarkscredentials_provideras supported on the kernel, plus one changelog entry.Differences from Thrift on the kernel path:
User-Agentis ignored, and the connector's is kept.OperationalError, where Thrift raisesRequestError. Both aredatabricks.sql.exc.Error.Testing
SELECT 1on the kernel)identity_federation_client_id(exchange refused, falls back)That run was dispatched from a temporary driver-test branch carrying PR #2423's AUTH-033 tests; AUTH-033 lands with databricks/databricks-driver-test#2423.
Unit and lint: these all pass.
Not run: Windows, macOS, and CI jobs that need a push.
Merge order
KERNEL_REVto the merged kernel commit6d6c1e4.databricks-sql-kernelfloor inpyproject.tomlandpoetry.lockmoves at that joint release, not in this PR.NotSupportedErrorforcredentials_provideronuse_kernel=True.This pull request and its description were written by Isaac.