Repository navigation
fix(platform): serve default branding when the organization is gone - #3023
Merged
Merged
Conversation
A stale bookmark/tab keeps calling readBranding with a deleted organization id until the dashboard bounces it, and the pre-auth action died in orgIdentityFromId's uncaught OrgSlugUnresolvableError on every visit. Catch the terminal miss, warn once, and serve the platform default bucket — the same result an org without a branding file gets. Transient lookup failures still propagate.
The unresolvable-org warn echoed the raw organizationId — an unauthenticated, unbounded string — verbatim, and dropped err.reason, the one bit that distinguishes a deleted org from a slugless row. Echo at most 64 chars plus the total length, and log the reason.
readBranding no longer treats slug resolution as an existence gate: an unresolvable org serves the platform default bucket (#3019). Update the three comments that still described the old throw (action args, module header, resolveBrandingDir).
Lock the two readBranding fallback paths the #3019 regression file missed: a live row without a slug folds into the default bucket (and the warn carries the reason), and a present default-bucket branding file is served with no appName, legacy brandColor coalesce intact. Also adopt vi.stubEnv like the sibling suites.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every visit to
/dashboard/<deleted org id>firesreadBranding(deadId)before the dashboard's recovery can bounce the tab, and the action dies inorgIdentityFromId's uncaughtOrgSlugUnresolvableError. One returning browser session with a stale bookmark has been minting exactly this since 2026-07-20 (GlitchTip 7489511 — every event taggedfunc: branding/file_actions:readBranding; 17 events, latest 2026-08-20 15:34:09 UTC, after this PR was first opened). Sibling issue 7489509 is the same error thrown fromproviders/file_actions:listProviders— a pre-#2876 path that stops on its own once demo runs a current build; only 7489511 is this endpoint. And becausereadBrandingis deliberately pre-auth (it backs the login shell), any anonymous client can mint uncaught server exceptions here with shape-invalid or deleted ids — an error/alert amplification vector, not just noise. (Ids that pass the id-shape guard but fail Convex id decode still throw inside the betterAuth component and are out of this file's reach — split to #3053.)Fixes #3019.
Why serving defaults is the right degradation
defaultbucket — exactly what every anonymous visitor on the login page already receives, and exactly what the same org would get if it merely had no branding file. No new information is exposed.BrandingProvideronly consumesdataand ignores errors (app/components/branding/branding-provider.tsx), so the page rendered defaults either way — now it does so without a burst of server exceptions per visit (previously ~4: the initial call plus 3useActionQueryretries, since the redacted error looked transient to the client).What changed
readBrandingcatches the terminal miss viaisOrgSlugUnresolvable, logs oneconsole.warn— carrying the miss reason (no_row/no_slug) and at most 64 chars of the (unauthenticated, unbounded) id — and falls back to thedefaultbucket. Transient transport errors (Better Auth adapter failure, network blip) still propagate, so retry layers keep seeing them. Write paths (saveBranding,saveImage, …) are untouched — they authenticate viarequireOrgMembershipById, which already reportsORG_NOT_FOUNDas a typedConvexError. The three doc comments that described resolution as an existence gate (action args, module header,resolveBrandingDir) are aligned with the new semantics.Tests
convex/branding/read_branding.test.ts(new):no_slugreason;appName, legacybrandColorcoalesce intact;appName;organizationId(pre-auth shell) → still readsdefault.Verifying after deploy
OrgSlugUnresolvableErrorevents taggedfunc: branding/file_actions:readBrandingstop appearing in GlitchTip (theculpritfield is empty on these server events — filter by thefunctag); 7489509 (listProviders) keeps counting until demo runs a current build. Then run the bulk-resolve checklist in #3019. Sibling tickets for the rest of the burst: #3020 (event grouping), #3021 (RLS typing), #3022 (trigger cascade), #3053 (shape-valid undecodable ids).Gate: oxfmt clean, oxlint clean, vitest
convex/branding/39 passed (3 files);tsc --noEmitandoxlint --type-awaregreen in CI.