Skip to content

Edge function JWT verification errors return { msg } instead of { error } in serve.main.ts #5861

Closed

Description

@shkuls

Affected area

Edge Functions

Supabase CLI version

Verified against develop (the JWT-verification code path in apps/cli/src/shared/functions/serve.main.ts hasn't changed recently, so this likely affects the latest published release too).

Operating system

N/A — source-level bug in the edge-runtime bootstrap template, reproducible on any OS running supabase functions serve / supabase start.

Command

supabase start
supabase functions serve   # or the equivalent local dev worker started by `supabase start`
curl -X POST http://127.0.0.1:<port>/<function-with-verify_jwt-true>

Actual output

{"msg":"Invalid JWT"}

Expected behavior

{"error":"Invalid JWT"}

matching the shape the platform edge-runtime gateway returns, and the shape already used elsewhere in the same file (serve.main.ts) for worker boot/crash errors ({ code, message }).

Steps to reproduce

  1. supabase start
  2. Deploy or serve a function with verify_jwt = true.
  3. Send a request with no Authorization header, or an invalid/wrongly-signed JWT.
  4. Observe the response body uses {"msg": "..."} instead of {"error": "..."}.

This means any consumer that reads the error key (matching the platform gateway's shape) never sees the real failure reason on supabase start — it silently falls through to a generic fallback message instead. This is exactly what happened in Supabase Studio's edge function test panel: see supabase/supabase#47835 for the full repro and root-cause writeup, and supabase/supabase#47836 for the Studio-side fix.

Additional context

@aantti requested fixing this at the source (this worker) rather than only patching Studio's error parsing — see the discussion on supabase/supabase#47836.

A fix is ready: two msg → error occurrences in apps/cli/src/shared/functions/serve.main.ts, plus the legacy Go CLI's bundled copy of the same template regenerated via the repo's own pnpm generate:go-serve-template script (kept in sync via the drift-guard test in serve-main-go-template.unit.test.ts), plus a new e2e test (serve-main-jwt-error-shape.e2e.test.ts) that boots the real bundled worker under edge-runtime and asserts on the response shape for both JWT-failure paths. Full functions/ test suite passes (6 files, 20 tests). Happy to open the PR once this issue is triaged and labeled open-for-contribution, per CONTRIBUTING.md.

Activity

  1. self-assigned this
    on Jul 11, 2026
  2. added
    open-for-contribution
    on Jul 11, 2026
  3. 7ttp commented on Jul 11, 2026

    @7ttp
    Member

    hey @shkuls thanks for reporting!
    taking this up on the cli side :)

  4. shkuls commented on Jul 11, 2026

    @shkuls
    Author

    Hey @7ttp , I have a draft PR ready, would be great if you can take a look and if this aligns with your idea.

  5. 7ttp commented on Jul 11, 2026

    @7ttp
    Member

    Hey @7ttp , I have a draft PR ready, would be great if you can take a look and if this aligns with your idea.

    :) I did already open a pr for the same here:

  6. shkuls commented on Jul 11, 2026

    @shkuls
    Author

    Oh no worries, however you seem fit :)

  7. removed
    open-for-contribution
    on Jul 21, 2026
  8. added a commit that references this issue on Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions