[SCAL-327336] Fix org tools disappearing after token expiry: reconcile token before getSessionInfo - #199
[SCAL-327336] Fix org tools disappearing after token expiry: reconcile token before getSessionInfo#199rohitthughtspot wants to merge 1 commit into
Conversation
…e token before getSessionInfo sessionInfo is fetched once at init via getSessionInfo(). Previously that ran before the keep-warm global token was reconciled from the token-store DO, so on a cold-start reconnect after the frozen props access token expired (~24h), getSessionInfo authenticated with the dead token, failed, and left sessionInfo null for the DO's lifetime — silently hiding list_orgs/switch_org and mis-gating feature flags, even though the DO still held a valid kept-warm token. - Reorder: a preInit() hook reconciles the global token from the token-store DO before initializeService()/getSessionInfo, so the init fetch authenticates with the kept-warm token and sessionInfo is populated correctly at connect. - ensureSessionInfo(): fallback in listTools that refetches session info if it's still null (e.g. a transient init failure), guarded by an in-flight promise so concurrent list calls share one fetch (no duplicate getSessionInfo / tracker). - isOrgsEnabled() defaults to true when sessionInfo is absent so org tools stay visible in the brief window before the refetch completes. - callTool reconciles the global token per call keyed on the absence of an active org token, so a data call always gets a fresh global token when no org token drives it. - Extract postInit's active-org bootstrap into ensureActiveOrg(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
df60ccb to
ee90ad1
Compare
|
@copilot review this change and identify any gaps or potential issues, but don't make any code changes yourself |
Here's a review of the changes with the notable gaps and potential issues: What the PR does well
Gaps and potential issues1. Feature flags from 2. Unbounded retries in If 3. Old: The new condition reconciles the global token even when org tools are available but no active org is selected (the old code would have skipped reconciliation in that case, since 4.
5.
6. Test for The concurrency test asserts SummaryThe core fix is sound and addresses the problem correctly. The most actionable gaps are #1 (session repair not covering |
SCAL-327336
Problem
After a cold-start reconnect (~24h, once the frozen props access token has expired),
list_orgs/switch_orgdisappear and feature-flag gating misbehaves — even though the keep-warm token is still valid.Cause
sessionInfois fetched once at init viagetSessionInfo(), which previously ran beforepostInitreconciled the keep-warm global token from the token-store DO. On a post-expiry reconnect the init fetch authenticated with the dead frozen props token, failed, and leftsessionInfonull for the DO's lifetime. Org-tool visibility and flag gating readsessionInfo, so they silently degraded — while the DO still held a valid token (data calls, which reconcile the DO token at call time, kept working).Fix
preInit()hook reconciles the global token from the token-store DO beforeinitializeService()/getSessionInfo, so the init fetch uses the kept-warm token andsessionInfopopulates correctly.ensureSessionInfo()— fallback inlistToolsthat refetches session info if it's still null (e.g. a transient init failure), guarded by an in-flight promise so concurrent list calls share one fetch (no duplicategetSessionInfo/ MixpanelTracker).isOrgsEnabled()defaults to true whensessionInfois absent, so org tools stay visible in the brief window before the refetch completes.callToolreconciles the global token per call keyed on the absence of an active org token.postInit's active-org bootstrap intoensureActiveOrg().Test
Regression test reproduces the failure (init
getSessionInfofails on an expired props token; DO holds a valid token) and asserts the repair restoressessionInfoand the org tools. Full suite passes (695 tests).Supersedes #184 (rebased onto latest main as a single clean commit).
🤖 Generated with Claude Code