Skip to content

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

Closed
@Dramelac

Description

@Dramelac

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions