Skip to content

fix(platform): serve default branding when the organization is gone - #3023

Merged
larryro merged 5 commits into
mainfrom
fix/branding-read-deleted-org
Aug 23, 2026
Merged

larryro merged 5 commits into
mainfrom
fix/branding-read-deleted-org

Conversation

@larryro

@larryro larryro commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Every visit to /dashboard/<deleted org id> fires readBranding(deadId) before the dashboard's recovery can bounce the tab, and the action dies in orgIdentityFromId's uncaught OrgSlugUnresolvableError. One returning browser session with a stale bookmark has been minting exactly this since 2026-07-20 (GlitchTip 7489511 — every event tagged func: 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 from providers/file_actions:listProviders — a pre-#2876 path that stops on its own once demo runs a current build; only 7489511 is this endpoint. And because readBranding is 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

  • The action's own doc claimed the slug resolution "already validates the org exists" — but that validation was an uncaught throw, and for this endpoint a terminal miss is a routine client state (stale bookmark), not a server fault. (The stale comments are aligned in this PR.)
  • The result served is the platform default bucket — 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.
  • Client-visible behavior is unchanged in practice: BrandingProvider only consumes data and 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 3 useActionQuery retries, since the redacted error looked transient to the client).

What changed

readBranding catches the terminal miss via isOrgSlugUnresolvable, logs one console.warn — carrying the miss reason (no_row/no_slug) and at most 64 chars of the (unauthenticated, unbounded) id — and falls back to the default bucket. 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 via requireOrgMembershipById, which already reports ORG_NOT_FOUND as a typed ConvexError. 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):

  • deleted org → resolves to the default-bucket result and warns once (was: uncaught rejection);
  • org row without a slug → default bucket, and the warn carries the no_slug reason;
  • default bucket has a branding file → served with no appName, legacy brandColor coalesce intact;
  • transient resolution failure → still rejects, before any file read;
  • live org → still resolves to its own bucket with the org name as appName;
  • no organizationId (pre-auth shell) → still reads default.

Verifying after deploy

OrgSlugUnresolvableError events tagged func: branding/file_actions:readBranding stop appearing in GlitchTip (the culprit field is empty on these server events — filter by the func tag); 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 --noEmit and oxlint --type-aware green in CI.

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.
@larryro
larryro merged commit 2eca245 into main Aug 23, 2026
69 of 70 checks passed
@larryro
larryro deleted the fix/branding-read-deleted-org branch August 23, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug service: platform Platform service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: every visit to /dashboard/<deleted org id> fires a burst of uncaught server errors — OrgSlugUnresolvableError / RLSError / ORG_NOT_FOUND

1 participant