Skip to content

Edge Functions Test panel always shows generic error for non-platform, hiding the real failure reason #47835

Open
sugata100/supabase
#3

Description

@shkuls

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

  1. Self-host Supabase (supabase start), deploy a function via supabase functions deploy <name>.
  2. Studio → Edge Functions → the function → Test → send a request that fails.
  3. 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:

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.

Activity

  1. added
    external-issue
    on Jul 10, 2026
  2. coderabbitai commented on Jul 10, 2026

    @coderabbitai
    Contributor
    🔗 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 plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 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:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  3. changed the title [-]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[/+] on Jul 10, 2026
  4. aantti commented on Jul 10, 2026

    @aantti
    Contributor

    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 main worker:

    • CLI - see 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)
    • Self-hosted - see docker/volumes/functions/main/index.ts
  5. added
    cli
    self-hosted
    and removed on Jul 10, 2026
  6. changed the title [-]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[/+] on Jul 10, 2026
  7. self-assigned this
    on Jul 10, 2026
  8. shkuls commented on Jul 11, 2026

    @shkuls
    Author

    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.

  9. shkuls commented on Jul 11, 2026

    @shkuls
    Author

    @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.

  10. self-assigned this
    on Jul 19, 2026
  11. added a commit that references this issue on Jul 29, 2026
  12. added a commit that references this issue on Sep 4, 2026
    a1401eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cliedge functionsexternal-issueself-hosted

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions