Skip to content

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

Closed

Description

@larryro

Problem

A browser session still holding a bookmark/deep link to a deleted organization has been hitting demo.tale.dev since 2026-07-18. Every visit fires the dashboard's initial round of org-scoped requests with the dead id, and each request dies on the server as an uncaught exception. This is live, not historical: the latest burst was 2026-08-19 17:30:51 UTC — all four grouped GlitchTip issues below gained +3 events within that same second (one visit = one burst).

Every event carries the same deleted org id (jh7csd7ks8740bza6qsxbz6sph7yegh2) and culprit /dashboard/; the latest event is from an authenticated user session — a returning visitor with a stale bookmark or pinned tab, not a crawler and not a cron.

GlitchTip issue Error Events
7489511, 7489509 Uncaught OrgSlugUnresolvableError: [orgSlugFromId] no organization row found for id "jh7csd…" 16 each
7489512 Uncaught ConvexError: {"code":"ORG_NOT_FOUND", …} via agents/file_actions:listAgents 16
7489510 Uncaught RLSError: Not a member of organization jh7csd… 16
~100+ single-event issues [CONVEX A(agents/file_actions:listAgents)] [Request ID: …] Server Error, same for listProviders, readBranding, … (browser-side console capture; the per-call Request ID keeps them from ever grouping — separate ticket, see comments) 1 each

The single-event pile alone was roughly a third of the demo project's total issue count (100+ of 327 at the 2026-08-12 review) — enough noise to bury a real regression, which is why this ran for a month.

Why every visit produces a burst (frontend recovery exists, but fires too late)

The dashboard already copes with a dead org id: the /dashboard/ index validates the session org id and the persisted lastActiveOrganizationId against the live membership list and falls back (app/routes/dashboard/index.tsx:66-86), and an already-mounted tab is bounced when getCurrentMemberContext pushes not_found (app/routes/dashboard/$id.tsx:223-238, tested). No redirect loop, no blank screen — which is exactly why nobody noticed.

But the URL itself is the org id (/dashboard/$id), so before the bounce can run, the page has already:

  1. prefetched org-scoped queries in the route loader ($id.tsx:63-78);
  2. published the id to BrandingProvider (mounted above the router) → readBranding(deadId) fires on every visit ($id.tsx:90-93);
  3. on a warm visit, restored the org shell from the sessionStorage hydration cache and mounted org-scoped children — listAgents, listProviders, RLS-guarded queries ($id.tsx:176-190).

Route-level recovery prevents loops; it cannot prevent the first round of requests per visit. The bug is that this first round crashes the server instead of failing predictably.

Where the server still crashes on current main

The credential-catalog / AI-backend rewrites (#2876, #2857) already moved the agents/providers public surface onto requireOrgMembershipById, which throws a typed ConvexError with code: 'ORG_NOT_FOUND' (convex/lib/auth/require_org_membership.ts) that the client treats as terminal — no retry (app/hooks/use-action-query.ts:56-59). Two paths still throw bare, uncaught errors on main:

  1. readBranding resolves the org via the throwing orgIdentityFromId:

    const identity = args.organizationId
    ? await orgIdentityFromId(ctx, args.organizationId)
    : null;

    Its own doc comment says "no membership gate — only the slug resolution, which already validates the org exists" — but that validation is an uncaught throw. And since readBranding is deliberately unauthenticated (pre-auth branding), any anonymous client can mint unlimited uncaught server exceptions with junk ids — an error/alert amplification vector. This ticket fixes this path.

  2. The RLS helper getOrganizationMember throws a bare RLSError, and mislabels "org deleted" as "not a member". Wide blast radius (~88 importing files), so it is split into its own ticket — see comments.

Suggested fix (this ticket)

Catch the terminal "unresolvable org" case in readBranding and serve the platform default branding bucket — the same semantics already used when an org has no branding file. Transient errors keep propagating. Display-only data, no auth implications, and BrandingProvider only reads data and ignores errors today (app/components/branding/branding-provider.tsx:66-79), so client-visible behavior is unchanged: defaults either way, minus the uncaught exception.

Proposed diff against 9a1e893 (written against current sources but not compiled/tested in the environment this was authored in; should ship with a branding/file_actions.test.ts case mocking orgIdentityFromId to throw OrgSlugUnresolvableError and asserting the default-bucket result):

diff --git a/services/platform/convex/branding/file_actions.ts b/services/platform/convex/branding/file_actions.ts
index 4d9edd9f..3ade2e71 100644
--- a/services/platform/convex/branding/file_actions.ts
+++ b/services/platform/convex/branding/file_actions.ts
@@ -38,7 +38,11 @@ import {
   readJsonFile,
   sha256,
 } from '../lib/file_io';
-import { orgIdentityFromId } from '../lib/helpers/org_slug';
+import {
+  isOrgSlugUnresolvable,
+  orgIdentityFromId,
+  type OrgIdentity,
+} from '../lib/helpers/org_slug';
 import type { BrandingJsonConfig, BrandingReadResult } from './file_utils';
 import {
   buildBrandingImageUrl,
@@ -126,9 +130,21 @@ export const readBranding = action({
     // The app name is the organization's own name (resolved here), not a
     // stored branding field — one source of truth for "what the org is
     // called". The pre-auth `default` bucket has no org, so no app name.
-    const identity = args.organizationId
-      ? await orgIdentityFromId(ctx, args.organizationId)
-      : null;
+    let identity: OrgIdentity | null = null;
+    if (args.organizationId) {
+      try {
+        identity = await orgIdentityFromId(ctx, args.organizationId);
+      } catch (err) {
+        // A stale tab/bookmark keeps requesting a deleted org's branding until
+        // the dashboard bounces it away — a terminal miss here is routine, not
+        // a server fault, so serve the platform `default` bucket instead of an
+        // uncaught throw. Transient transport errors still propagate.
+        if (!isOrgSlugUnresolvable(err)) throw err;
+        console.warn(
+          `[Branding] readBranding: unresolvable organization ${JSON.stringify(args.organizationId)}; serving default branding`,
+        );
+      }
+    }
     const orgSlug = identity?.slug ?? DEFAULT_ORG_SLUG;
     const fileResult = await readBrandingFile(orgSlug);
 

Verifying / cleanup after deploy

  • The 2026-08-19 server events still tag pre-rewrite function names (func: agents/file_actions:listAgents), i.e. the demo deployment predates refactor(platform)!: retire "integration" and rebuild the credential catalogs #2876 — part of the burst stops on its own once demo runs a current build. readBranding and the RLS path crash on today's main too, hence this ticket.
  • After deploy: bulk-resolve GlitchTip issues matching OrgSlugUnresolvable, ORG_NOT_FOUND, and Not a member of organization jh7csd, then watch a week for the same errors under the new function names (agents/actions:listAgents, provider_credentials/queries:listCredentials, …).

Related prior art: #2668 (uncaught ORG_NOT_FOUND from an empty org id — closed), #2018 (raw Errors in org/user lifecycle mutations — closed).

Activity

  1. added
    priority: high
    bug
    service: platform
    on Aug 20, 2026
  2. larryro commented on Aug 20, 2026

    @larryro
    ContributorAuthor

    Follow-up tickets split from this incident:

    This issue itself covers the readBranding fix (patch in the description) plus the GlitchTip verification/cleanup checklist.

  3. larryro commented on Aug 20, 2026

    @larryro
    ContributorAuthor

    PR set for this incident, one per ticket (each is independent off main):

    After all four deploy, run the GlitchTip verification/bulk-resolve checklist in this ticket's description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: highservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions