Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supabase invoke function doesn't handle custom error status code #192

Closed
2 tasks done
Dramelac opened this issue Feb 24, 2025 · 0 comments · Fixed by #196
Closed
2 tasks done

Supabase invoke function doesn't handle custom error status code #192

Dramelac opened this issue Feb 24, 2025 · 0 comments · Fixed by #196
Assignees
Labels
bug Something isn't working

Comments

@Dramelac
Copy link

Dramelac commented Feb 24, 2025

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When using supabase_client.functions.invoke("function-name") and the edge-function return a custom error code like 403 with a body like {"error":"Unauthorized"}, the raised exception override the status code to 400, only the error message can be retrieved from the original server response.

In more details:
The function-py sub-lib raise a FunctionsHttpError here when the response is not 200 (as expected):


But the FunctionsHttpError have an hardcoded status code of 400 here:

To Reproduce

Create an edge-function that return a custom error code and invoke it from supabase-py lib:

return new Response(JSON.stringify({error: "Unauthorized"}), {
    status: 403,
    headers: {"Content-Type": "application/json; charset=utf-8"}
});

Expected behavior

The FunctionsHttpError exception should be configured with the real status code from the edge-function response.

Screenshots

Image

System information

  • Version of supabase-py: 2.13.0
  • Version of supabase-edge-runtime: 1.67.0
@Dramelac Dramelac added the bug Something isn't working label Feb 24, 2025
@grdsdev grdsdev transferred this issue from supabase/supabase-py Feb 25, 2025
@silentworks silentworks self-assigned this Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants