Repository navigation
Description
Bug: On self-hosted Supabase, the Edge Functions Test panel in Studio always shows the same generic error — Edge function returned an error — no matter what actually failed (thrown exception, timeout, gateway/DNS issue, malformed input, anything). This happens 100% of the time, not intermittently.
Root cause: apps/studio/pages/api/edge-functions/test.ts extracts the error message by reading errorBody?.error:
error: { message: errorBody?.error || 'Edge function returned an error' }But self-hosted's Kong-fronted edge runtime returns errors shaped as {"message": "..."}, not {"error": "..."}. The key never matches, so it always falls through to the hardcoded string. This logic was written for the platform-only version of this endpoint and never re-validated against self-hosted's actual response shape when self-hosted test support was added in #42350.
To reproduce
- Self-host Supabase (
supabase start), deploy a function viasupabase functions deploy <name>. - Studio → Edge Functions → the function → Test → send a request that fails.
- Response shows the generic message regardless of the real cause.
Proof — curl against the raw edge runtime vs. Studio's test-proxy endpoint, before/after the fix:
# the real error, straight from the edge runtime
$ curl -X POST http://127.0.0.1:54321/functions/v1/og-images -d '{}'
{"message":"name resolution failed"}
# Studio's proxy, same failure — before fix (master@d5fde192d5)
$ curl -X POST http://localhost:8082/api/edge-functions/test -d '{"url":"...","method":"POST","body":"{}","headers":{}}'
{"status":503,"error":{"message":"Edge function returned an error"}}
Also confirmed in the Studio UI itself (Test → Send Request): before the fix shows "Edge function returned an error"; this is unchanged for gateway-level failures (see Wider fix below for why), but is now fixed for worker-level failures since the worker itself emits the right key.
Fix: #47836 — fixes the self-hosted worker (docker/volumes/functions/main/index.ts) to emit error instead of msg, matching the shape Studio's proxy already expects (errorBody?.error). No change needed on Studio's side once the source emits the right key — Studio's original single-key error check was left as-is, per @aantti's feedback below.
Wider fix
@aantti pointed out this should be fixed at the source rather than only patched in Studio (see #47836). The same msg/error inconsistency existed in the other places that generate edge function error responses. Fixed to match platform's error shape everywhere it's under our control:
- Self-hosted docker-compose worker (
docker/volumes/functions/main/index.ts) — fixed, part of fix(studio): surface real error message from self-hosted edge function test #47836 supabase startlocal dev worker (supabase/cli'sapps/cli/src/shared/functions/serve.main.ts, plus the legacy Go CLI's bundled copy) — fix(cli): jwt errors cli#5862- Docs examples teaching the same pattern (
examples/edge-functions/supabase/functions/sentryfied/index.tsand the shared_shared/jwt/*auth middlewares) — docs(edge-functions): use error key in examples #47849
Gateway-level errors (e.g. Kong routing failures, the specific case reproduced above) happen before any worker script runs, so they can't be fixed at the source. Per @aantti, Studio doesn't special-case these — they still show the generic fallback message, and that's expected.
Known limitation: doesn't handle nested error objects (e.g. {"error": {"message": "..."}}) or non-JSON gateway error pages (e.g. raw HTML from a 502/504) — flagged as a follow-up, not blocking.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
coderabbitai commentedon Jul 10, 2026
🔗 Related PRs
#42130 - fix(self-host): add hybrid JWT verification for edge functions docker template [closed]
#43475 - Supabase edge functions 401 troubleshooting [closed]
#43488 - Supabase edge functions 404 troubleshooting [closed]
#43628 - Capture exception in edge functions body query [closed]
#47602 - test(self-hosted): add an e2e test for exposed schemas in data api ui [merged]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
[-]Self-hosted Edge Functions Test panel always shows generic error, hiding the real failure reason[/-][+]Local-dev/CLI Edge Functions Test panel always shows generic error, hiding the real failure reason[/+]aantti commentedon Jul 10, 2026
Thanks, @shkuls :) Re
supabase start- this seems to be specific to local development & CLI (not self-hosted Supabase), please correct the description.CLI and self-hosted have different variants of the
mainworker:apps/cli/src/shared/functions/serve.main.ts(and the legacy CLI-go used this, I think -apps/cli-go/internal/functions/serve/templates/main.bundled.js)docker/volumes/functions/main/index.ts[-]Local-dev/CLI Edge Functions Test panel always shows generic error, hiding the real failure reason[/-][+]Edge Functions Test panel always shows generic error for non-platform, hiding the real failure reason[/+]shkuls commentedon Jul 11, 2026
Sure @aantti. Thanks for the review. I did a deeper dive on the main worker variants. I am widening the scope of my work to cover everything in a more optimised way.
shkuls commentedon Jul 11, 2026
@aantti Filed the CLI-side issue: supabase/cli#5861. Same root cause (msg vs error), fix is already written and tested against apps/cli/src/shared/functions/serve.main.ts (plus the legacy Go CLI's bundled copy, regenerated from the same source), just needs the open-for-contribution label per CONTRIBUTING.md before I can open the PR.
fix(cli): jwt errors (supabase#5862)
fix(self-hosted): emit error key from edge functions worker