Invoke supabase function returns 4xx/5xx status code, but the plugin considers it as success

Hello WeWeb community,

I’m using the Supabase plugin to invoke my edge functions, and I’m struggling with how the plugin identifies errors in the function response.

The Edge Function returns 400 or 500, but the plugin doesn’t trigger the OnError part of the workflow.

The response body contains a JSON object with “{“error”: “Something wrong happened”}”.

Am I missing anything when calling the function from WeWeb? Do I need to return something specific so the plugin identifies 4xx or 5xx status codes as errors?

I’m adding a few screenshots to show what I’m seeing in the Network console and the editor.

onError - never triggered

Console error 400s

Logs with success message

Green

Thank you!

Please open a ticket on support.weweb.io, we will give a look, normally if the error is well formed it should throw, maybe it’s an issue related to the specific code you have in your edge function :thinking:

Thanks @Alexis! I’ve opened a ticket like you said. I’m happy to share my Edge Function code if necessary, but it’s a simple response with 400 status as shown in the console.

I’ll wait to see if you guys need more data on this one.

Thanks for helping.

1 Like

In the console (dev mode) you can navigate to Network (tab) and you can inspect the Network calls, if you open up the response of your 40X requests, there usually is a hint, or a reason behind the error.

I think his issue was not about knowing the root cause but rather how to make the workflow throw and execute the onError side

That’s weird because we use the recommended supabase way to handle edge functions errors => Developing Edge Functions locally | Supabase Docs

But in his case, the error is not recognized as any of the possible error types. I pushed a fix to add another case to handle unrecognized error, that should be enough, it’s in QA right now :slight_smile:

I haven’t tried executing my function using the SDK directly. I can try it to find out if I can help you debug this one.

Do you have any idea how much we can have that change from QA to prod? :smile:

Thanks for looking into to this!