Repository navigation
Conversation
…n test
Self-hosted's Kong-fronted edge runtime returns errors as
{"message": "..."}, but the test-invoke proxy only checked
errorBody?.error. This meant every failed test request in self-hosted
(network issue, thrown exception, timeout, etc.) showed the same
generic "Edge function returned an error" instead of the actual cause.
Move the error-shape handling out of the API route into a pure, testable getEdgeFunctionErrorMessage() helper in lib/api/edgeFunctions.ts, matching the existing pattern used by isValidEdgeFunctionURL in the same file. Covers self-hosted vs platform error shapes, non-string fields, malformed JSON, and empty bodies.
|
Thanks for contributing to Supabase! ❤️ Our team will review your PR. A few tips for a smoother review process:
|
|
@shkuls is attempting to deploy a commit to the Supabase Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe changes standardize edge function runtime error payloads on the ChangesEdge Function Error Handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Thanks, but tbf, I think it's best to fix the See the following:
|
|
Agreed, patching at the source is the right call. I'll open PRs to normalize those to error. One thing worth flagging tho, the specific failure in the issue (name resolution failed) never actually reaches the worker script. It's Kong's own 503 when it can't route to the edge-runtime container (confirmed via the Server: kong response header). That happens upstream of any worker code, so no worker-side fix can normalize it. This is the same for any errors from user's own functions. Hence this Studio defensive parsing is necessary for that class of errors. |
…nses
The self-hosted docker-compose functions main worker returned failures
as { msg: "..." }, inconsistent with the platform gateway's { error: "..." }
shape that Studio's edge function test panel checks for.
Aligns JWT verification, missing-function-name, and worker-creation
failures to { error: "..." }, matching platform. Complements the CLI
fix in supabase/cli (apps/cli/src/shared/functions/serve.main.ts) and
Studio's defensive parsing in lib/api/edgeFunctions.ts, which stays
necessary for gateway-level errors (e.g. Kong routing failures) that
never reach this worker script at all.
|
@shkuls Correct, when no functions container running or something is wrong with the upstream, Kong will return |
|
Oh I see, did not know about Kong being deprecated. In that case, wdyt should I still keep the parsing as it also handles a user function emitting |
|
I'm still not sure this change to Studio is required, btw, @shkuls. This is too much customization. |
|
I see @aanti :) I will remove the |
My preference would be to align CLI's and self-hosted's |
|
Sure, thanks for your review. The error parsing still doesn't cover all the cases (and we possibly cannot ig) so its better to remove it. I will remove the specific parsing and revert the |
Per aantti's feedback on supabase#47836, gateway-level failures (e.g. Kong routing errors) happen before any worker script runs and can't be fixed at the source, so special-casing them in Studio is unnecessary customization. The self-hosted worker itself (docker/volumes/functions/main/index.ts) now emits `error` consistently, so the original single-key check is sufficient.
|
any updates here @7ttp ? |
7ttp
left a comment
There was a problem hiding this comment.
had another look after the discussions
I don’t think msg → error is the right direction here
could we instead align this w the { code, message } pattern and include
sb-error-code for failures, as we’re doing elsewhere?
thoughts? @aantti
Fixes #47835
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
On self-hosted Supabase, the Edge Functions Test panel shows the same generic
Edge function returned an errormessage for every failure, regardless of cause. The proxy endpoint (pages/api/edge-functions/test.ts) only checked anerrorkey when parsing the edge runtime's JSON error body, but self-hosted's Kong-fronted edge runtime returns errors shaped as{"message": "..."}, so the key never matched and the real reason was always discarded. See #47835 for full repro and before/after proof.What is the new behavior?
The proxy now checks
message(self-hosted shape) first, falls back toerror(platform shape), then the generic string as a last resort. Extracted the parsing logic into a puregetEdgeFunctionErrorMessage()helper inlib/api/edgeFunctions.ts, alongside the existingisValidEdgeFunctionURL, covered by unit tests for the shape permutations (self-hosted shape, platform shape, both present, non-string/empty fields, non-JSON body, empty body).Additional context
getEdgeFunctionErrorMessageunit tests pass (apps/studio/lib/api/edgeFunctions.test.ts)tsc --noEmitcleanEdge function returned an error; after the fix it shows the real reason,name resolution failedSummary by CodeRabbit