Repository navigation
FE-3440 fix(billing): scope the token-session billing SDK by the user its Cloud JWT names - #21005
dante01yoon wants to merge 2 commits into
Conversation
… not the Firebase uid The billing SDK on the token session scopes itself by the Firebase uid, but /billing/capabilities answers resolved_for.user_id with the Comfy user id the Cloud JWT names. For a linked identity the two differ and the capabilities reader drops the 200 as out of scope. FE-3440
…ud JWT names On the token session the billing SDK took its scope user from the Firebase uid. /billing/capabilities answers resolved_for.user_id with the Comfy user id the Cloud JWT was issued for, and since identity mappings a Firebase subject can link to an existing Comfy user, so the two differ for linked accounts. The capabilities reader then rejected every 200 as out of scope: no Upgrade plan button, Change to Pro inert, capability_read.failed on every load. The web session already scopes by the server's user id. The token-session scope now reads the user from the minted Cloud JWT's sub, the identity the server resolves the request to. FE-3440
📦 Bundle: 9.44 MB gzip 🔴 +779 BDetailsSummary
Category Glance App Entry Points — 5.02 kB (baseline 4.98 kB) • 🔴 +40 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 2.45 MB (baseline 2.45 MB) • 🔴 +95 BGraph editor runtime, canvas, workflow orchestration
Status: 2 added / 2 removed / 1 unchanged Views & Navigation — 147 kB (baseline 147 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 6 added / 6 removed / 12 unchanged Panels & Settings — 670 kB (baseline 670 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 3 added / 3 removed / 26 unchanged User & Accounts — 275 kB (baseline 275 kB) • 🔴 +42 BAuthentication, profile, and account management bundles
Status: 3 added / 3 removed / 14 unchanged Editors & Dialogs — 340 kB (baseline 340 kB) • 🔴 +39 BModals, dialogs, drawers, and in-app editors
Status: 5 added / 5 removed / 7 unchanged UI Components — 212 kB (baseline 212 kB) • ⚪ 0 BReusable component library chunks
Status: 3 added / 3 removed / 21 unchanged Data & Services — 2.17 MB (baseline 2.17 MB) • 🔴 +39 BStores, services, APIs, and repositories
Status: 2 added / 2 removed / 22 unchanged Utilities & Hooks — 999 kB (baseline 999 kB) • 🔴 +547 BHelpers, composables, and utility bundles
Status: 13 added / 13 removed / 50 unchanged Vendor & Third-Party — 13.9 MB (baseline 13.9 MB) • ⚪ 0 BExternal libraries and shared vendor chunks Status: 17 unchanged Other — 19.4 MB (baseline 19.4 MB) • 🔴 +465 BBundles that do not match a named category
Status: 51 added / 50 removed / 298 unchanged ⚡ Performance
🔬 E2E Coverage
🎨 Storybook: ✅ Built — View Storybook🌾 Fallow: ❌ FailedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. Fallow reports a failing verdict, but this renderer found no findings it Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since d3818ea6b8a93d5ff55b3a677816c8f590494530
Full docs: ADR-DEVEX-LINT-0015 |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 4
✨ Finishing Touches
Comment |
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 4 Pipeline jobs failed
Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: 1117dcc | Docs | View more details | Give us feedback! |
|
Superseded by #21004 (FE-3441), which fixes the same capabilities read on the token session. Closing this duplicate. |
Summary
On the token session (
unified_web_sessionoff,unified_cloud_authon) with the billing SDK rail on, an account whose Firebase uid differs from its Comfy user id never resolves billing capabilities: no Upgrade plan button, "Change to Pro" does nothing,billing.capability_read.failedon every load. The SDK now scopes the token session by the user its Cloud JWT names.Why
GET /api/billing/capabilitiesanswers 200 withcan_subscribe_self_serve: true, but the UI never sees it. It works withunified_web_sessionon.Root cause
billingSdkStorebuilt the token-session SDK with account-core's default scope source, which takesuserIdfrom the Firebase user (state.user.uid). The billing API resolvesresolved_for.user_idto the canonical Comfy user id, thesubof the Cloud JWT. Since identity mappings, a new Firebase subject (second provider, SSO) can link to an existing Comfy user, so the two ids differ. The capabilities reader treats aresolved_forthat does not match its scope as a contract violation (REQUEST_FAILED), so capabilities stay null. The web session already scopes by the server's user id, which is why it works there.Evidence for the QA account (PostHog staging): token-session sessions identify as Firebase uid
EJfiug…and fail;resolved_for.user_idand the web-session user areC3Niv…and succeed.How
On the token session, the store hands the SDK a scope source that reads the user from the minted Cloud JWT's
sub(the same claim reader local web sign-in uses), with the workspace and role from the credential. Nothing is derived:subis the identity the server resolved the token to and echoes inresolved_for. A BE follow-up could return the user id onPOST /api/auth/tokenso the claim read is not needed.Impact
Present on
main,cloud/1.57andcloud/1.56(prod). Prod is on the token session for everyone, so linked-identity users on the SDK rail are affected; Sentry prod shows theREQUEST_FAILED+ HTTP 200 capability signature (2 users, 188 events in 14 days), and exposure grows with SSO.Verification
billingSdkStore.tokenSession.test.tsruns the real billing SDK through the store on the token session with a Firebase uid that differs from the token'ssub; it fails onmain(status: 'error') and passes with the fix.vitest run src/platform/workspace/billing/sdk/ useBillingCapabilities useSubscriptionOperationView TopUpCreditsDialogContentWorkspace src/platform/auth/localWeb: 512 passed.AS IS / TO BE