Skip to content

fix(functions): use error key for JWT verification failures in serve.main.ts#5863

Draft
shkuls wants to merge 2 commits into
supabase:developfrom
shkuls:fix/serve-main-error-key-consistency
Draft

fix(functions): use error key for JWT verification failures in serve.main.ts#5863
shkuls wants to merge 2 commits into
supabase:developfrom
shkuls:fix/serve-main-error-key-consistency

Conversation

@shkuls

@shkuls shkuls commented Jul 11, 2026

Copy link
Copy Markdown

Summary

Aligns JWT-verification failure responses in the edge-runtime bootstrap template (apps/cli/src/shared/functions/serve.main.ts) from { msg: "..." } to { error: "..." }, matching the platform gateway's shape and the { code, message } shape already used elsewhere in the same file for worker boot/crash errors. Regenerates the legacy Go CLI's bundled copy of the same template (apps/cli-go/internal/functions/serve/templates/main.bundled.js) via the repo's own pnpm generate:go-serve-template script, so the drift-guard test (serve-main-go-template.unit.test.ts) stays green. Adds an e2e test that boots the real bundled template under edge-runtime and asserts on the response shape for both JWT-failure paths (missing Authorization header, wrongly-signed token).

Linked issue

Closes #5861

  • The linked issue is open and carries the open-for-contribution label.

Checklist

  • The PR title follows Conventional Commits (fix(functions): …).
  • Tests added or updated for the change (new e2e test; verified it fails against the pre-fix code and passes against the fix).
  • pnpm test passes for apps/cli (functions/ suite: 6 files, 20 tests).

shkuls added 2 commits July 11, 2026 16:33
…main.ts

The edge-runtime bootstrap template returned JWT verification failures
as { msg: "..." }, inconsistent with the platform gateway's { error: "..." }
shape. Consumers (e.g. Studio's edge function test panel) that check the
error key never see the real failure reason on `supabase start`.

Aligns both JWT-failure paths to { error: "..." }, matching the shape
already used elsewhere in this same file for worker boot/crash errors.
Regenerated the Go CLI's bundled copy of the template (drift-guard test
in serve-main-go-template.unit.test.ts) and added an e2e test that boots
the real bundled template under edge-runtime and asserts on the response
shape for both JWT-failure paths (missing header, wrongly-signed token).

Related: supabase/supabase#47835, supabase/supabase#47836
The container log wait already gates on "Serving functions on" before
any request is sent, and Docker's -p port mapping is live from
container creation, not app-listen time — the extra waitForServer()
HTTP poll was redundant. Matches the existing offline e2e test in this
file, which trusts the same log-based readiness signal with no
additional HTTP check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant