Repository navigation
Conversation
FederationProvider performed an RFC 8693 token exchange on every getToken() call, which the Thrift path issues per HTTP request. Cache the exchanged token and reuse it while the subject token is unchanged and the exchanged token is not within the 5-minute refresh threshold shared with CachedTokenProvider. Concurrent callers share one in-flight exchange, and failures or fallback results are never cached, so the next call re-attempts. 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 Medium · 1 Nit
Looks good, with 2 low concerns. The caching, coalescing and no-caching-on-failure behavior is correct and well tested. The remaining gaps are stale finally cleanup when the subject token rotates mid-exchange, and no test for the JWT exp fallback.
Other findings
- ⚪ Nit — The JWT
expfallback whenexpires_inis missing has no test. Only the non-JWT 1-hour default is covered. Add a test with a JWT access_token that hasexpand noexpires_in, and assertexpiresAtequalsexp * 1000. (Found by Claude Opus 5.5 · confirmed by the judge)
A late-settling exchange for an older subject cleared the shared in-flight reference even after a newer subject's exchange had replaced it, causing duplicate exchanges, and could evict the newer subject's cached entry. Track each exchange's own promise and only clear the shared fields when it is still the tracked exchange; write the cache only while the exchange is still tracked for its subject. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
When returnOriginalTokenOnFailure is enabled and the exchange fails, cache the original token for the subject and re-attempt the exchange at most once per 5 minutes (or when the subject token changes or nears expiry), matching the Python driver, instead of failing on every call. A successful exchange replaces the fallback cache; errors with returnOriginalTokenOnFailure disabled still throw and are not cached. 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: 2 Low
Looks good, with one low-severity test gap. Caching, request coalescing and the stale-settlement guards are correct, and the federation provider wraps CachedTokenProvider, so subject token strings stay stable between refreshes.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Resolve the newer subject's exchange first so a missing cache-write guard lets the stale exchange evict its entry, and add a test that settles the older exchange first to cover the in-flight reference clear guard. Both tests fail when their guard is removed. 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, no blocking issues. The caching, fallback interval, coalescing and stale-write guards are correct for the CachedTokenProvider → FederationProvider wiring in DBSQLClient.wrapTokenProvider, and the unit tests cover each path.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Found while reviewing #656: with
enableTokenFederation,FederationProviderperformed an RFC 8693 token exchange at/oidc/v1/tokenon everygetToken()call. The Thrift path calls this per HTTP request (and the kernel's token provider per request too), so each request paid a network exchange plus retries.What changes
CachedTokenProvider). A changed subject token or a near-expiry exchanged token triggers a re-exchange.returnOriginalTokenOnFailure: falsestill throws immediately and caches nothing.expires_in, the token now falls back to its JWTexpclaim, then to a 1-hour default lifetime, so the cache is always bounded.Tests
FederationProviderunit tests: one exchange per subject, re-exchange on subject change or near expiry, concurrent coalescing, mid-flight subject swap, fallback caching with re-attempt after the 5-minute interval or a subject change,returnOriginalTokenOnFailure: falsethrows without caching, exp and default TTL fallbacks.npm run build,npm run lint,npm run prettierandnpm run test(1904 unit tests) pass. No e2e or live tests run.This pull request and its description were written by Isaac.