Skip to content

[SCAL-327336] Fix org tools disappearing after token expiry: reconcile token before getSessionInfo - #199

Open
rohitthughtspot wants to merge 1 commit into
mainfrom
fix/sessioninfo-reorder-repair
Open

[SCAL-327336] Fix org tools disappearing after token expiry: reconcile token before getSessionInfo#199
rohitthughtspot wants to merge 1 commit into
mainfrom
fix/sessioninfo-reorder-repair

Conversation

@rohitthughtspot

@rohitthughtspot rohitthughtspot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

SCAL-327336

Problem

After a cold-start reconnect (~24h, once the frozen props access token has expired), list_orgs/switch_org disappear and feature-flag gating misbehaves — even though the keep-warm token is still valid.

Cause

sessionInfo is fetched once at init via getSessionInfo(), which previously ran before postInit reconciled 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 left sessionInfo null for the DO's lifetime. Org-tool visibility and flag gating read sessionInfo, 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

  • Reorder — a preInit() hook reconciles the global token from the token-store DO before initializeService()/getSessionInfo, so the init fetch uses the kept-warm token and sessionInfo populates correctly.
  • 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 / MixpanelTracker).
  • 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.
  • Extract postInit's active-org bootstrap into ensureActiveOrg().

Test

Regression test reproduces the failure (init getSessionInfo fails on an expired props token; DO holds a valid token) and asserts the repair restores sessionInfo and the org tools. Full suite passes (695 tests).

Supersedes #184 (rebased onto latest main as a single clean commit).

🤖 Generated with Claude Code

…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>
@rohitthughtspot
rohitthughtspot force-pushed the fix/sessioninfo-reorder-repair branch from df60ccb to ee90ad1 Compare August 5, 2026 18:10
@rohitthughtspot rohitthughtspot changed the title Fix org tools disappearing after token expiry: reconcile token before getSessionInfo [SCAL-327336] Fix org tools disappearing after token expiry: reconcile token before getSessionInfo Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant