Skip to content

Bug: ids that pass the id-shape guard but fail Convex decode still mint uncaught component-side errors #3053

Closed as not planned

Description

@larryro

Residual of #3019, split out of the PR #3023 review: that PR stops the uncaught errors for shape-invalid junk and for well-formed ids whose org row is gone, but one class remains anonymously mintable on the pre-auth readBranding surface.

Mechanics

looksLikeConvexDocumentId (services/platform/convex/lib/helpers/id_shape.ts) deliberately accepts a generous band (/^[0-9a-z]{20,64}$/) so a future id-length change cannot reject real ids. A string inside that band that is not a decodable Convex id (e.g. 'l'.repeat(21)) passes the guard, reaches the betterAuth component, and the adapter resolves _id eq filters with a bare ctx.db.get(value) (@convex-dev/better-auth dist/client/adapter-utils.js, value validated only as v.string()). The backend decode then throws (Unable to decode ID), and:

  • the throw crosses runQuery as a generic error, so isOrgSlugUnresolvable correctly does NOT match it and readBranding rethrows (convex/branding/file_actions.ts — matching generic errors there would swallow real transport failures, so the caller-side catch is right as-is);
  • per id_shape.ts's own doc, a thrown component query is recorded as an uncaught server error even when the platform-side caller catches the rejection — so this cannot be silenced from the caller at all.

Since readBranding is deliberately unauthenticated, an anonymous client can mint these at will — the same amplification class as #3019, under a different signature (Unable to decode ID, not OrgSlugUnresolvableError).

Suggested fix (at the source, not in branding)

  1. A betterAuth-side lookup that runs ctx.db.normalizeId('organization', value) first (returns null for undecodable ids — see convex database_impl) and treats null as the terminal miss; or
  2. tighten looksLikeConvexDocumentId to the exact production length band (trade-off: its doc says the band is generous on purpose).

Coordination: #3052 rewrites org_slug.ts / RLS error typing but touches neither id_shape.ts nor the adapter path, so this stays open either way.

Verifying

After the fix, junk of any shape on pre-auth readBranding produces zero uncaught server events — watch GlitchTip for Unable to decode ID under func: branding/file_actions:readBranding (the culprit field is empty on Convex server events; filter by the func tag).

Activity

  1. yannickmonney commented on Sep 27, 2026

    @yannickmonney
    Contributor

    Closing as obsolete. 0.5.0 (#3107) moved the platform off Convex: the pre-auth branding read (GET /api/app/branding) is now a parameterised SELECT … WHERE "id" = $1, and an unknown id gets the default branding plus a warning. A NUL byte is refused earlier by nulUrlGuard (backend/lib/http-hygiene.ts), and nothing records component-side throws any more.

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

    bugservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions