Skip to content

docs(edge-functions): use error key in examples - #47849

Open
shkuls wants to merge 2 commits into
supabase:masterfrom
shkuls:docs/edge-function-example-error-key
Open

shkuls wants to merge 2 commits into
supabase:masterfrom
shkuls:docs/edge-function-example-error-key

Conversation

@shkuls

@shkuls shkuls commented Jul 11, 2026 •

Copy link
Copy Markdown

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Docs update

What is the current behavior?

Several edge function examples (examples/edge-functions/supabase/functions/sentryfied/index.ts, and the shared JWT auth middlewares _shared/jwt/default.ts, _shared/jwt/clerk.ts, _shared/jwt/legacy-jwt.ts) return errors as { "msg": "..." }. This doesn't match the shape Supabase's own tooling expects (platform gateway, self-hosted worker, Studio's test panel all use { "error": "..." }) — see #47835 for the full writeup of this pattern across the codebase. A developer copying any of these would hit the same "generic unhelpful error" symptom that issue describes, just caused by their own function.

The three _shared/jwt/* files are auth middleware imported by multiple example functions, so fixing them there covers every example that uses AuthMiddleware from any of the three, not just the one function that imports it directly.

What is the new behavior?

All four return { "error": "..." } instead, matching platform's shape and the now-fixed self-hosted/CLI workers.

Additional context

Related to #47835. Not a functional bug in any of these examples (JWT verification and Sentry capture still work either way), just aligning the taught pattern with what Supabase's own tooling actually expects.

Summary by CodeRabbit

  • Bug Fixes
    • Standardized authentication and error payloads to use the error field instead of msg.
    • Ensured invalid or failed JWT validation continues to return HTTP 401.
    • Updated error responses for the affected edge-function examples to return consistent { error: ... } JSON when failures occur.

Several edge function examples returned errors as { msg: ... }, which
doesn't match the shape Supabase's own tooling expects (platform
gateway, self-hosted worker, Studio's test panel all use
{ error: ... }, see supabase#47835). A developer copying these examples would
hit the same generic-error symptom, just caused by their own function.

The _shared/jwt/* middlewares are imported by multiple example
functions, so fixing them covers every example that uses
AuthMiddleware, not just sentryfied.
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to Supabase! ❤️ Our team will review your PR.

A few tips for a smoother review process:

  • If you have a local version of the repo, run pnpm run format to make sure formatting checks pass.
  • Once we've reviewed your PR, please don't trivially merge master (don't click Update branch if there are no merge conflicts to be fixed). This invalidates any pre-merge checks we've run.

@vercel

vercel Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment Jul 11, 2026 3:54pm

Request Review

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

@shkuls is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5f0176b8-1963-43af-a2ce-eafce9abcc2a

📥 Commits

Reviewing files that changed from the base of the PR and between 6fe5e2f and c917e8e.

📒 Files selected for processing (1)
  • examples/edge-functions/supabase/functions/sentry/index.ts

📝 Walkthrough

Walkthrough

JWT middleware and Sentry Edge Functions now return error payloads under error instead of msg, while preserving existing error values and HTTP status codes.

Changes

Error response standardization

Layer / File(s) Summary
Update failure response payloads
examples/edge-functions/supabase/functions/_shared/jwt/*, examples/edge-functions/supabase/functions/sentry*/index.ts
JWT authentication failures and Sentry handler errors now use the error response field instead of msg. Existing status codes and error values remain unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • Issue 47835 — Standardizes Edge Function error responses from msg to error for consistent failure details.

Suggested reviewers: ChrisChinchilla, alaister, ivasilov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly reflects the main change: switching example error payloads to use the error key.
Description check ✅ Passed The description matches the template and fills all required sections with clear context and behavior details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/edge-functions/supabase/functions/sentryfied/index.ts`:
- Line 28: Update the remaining 500 response in the Sentry edge function so its
response body uses the error key instead of msg, preserving the existing error
value and status; leave the oak-server msg response unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 367c75e6-ea55-4219-ab76-edce3d5ff6ef

📥 Commits

Reviewing files that changed from the base of the PR and between 1ce1fd6 and 6fe5e2f.

📒 Files selected for processing (4)
  • examples/edge-functions/supabase/functions/_shared/jwt/clerk.ts
  • examples/edge-functions/supabase/functions/_shared/jwt/default.ts
  • examples/edge-functions/supabase/functions/_shared/jwt/legacy-jwt.ts
  • examples/edge-functions/supabase/functions/sentryfied/index.ts

Same msg/error inconsistency as the other examples fixed in this PR,
flagged by review on the 500 response in the Sentry Functions
Challenge example.

This branch has not been deployed

No deployments
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.

1 participant