Raising an exception on postgress via triggers doesn't send the message to the API response #1602
Closed
2 tasks done
Labels
bug
Something isn't working
Bug report
Describe the bug
Note
The reason I'm adding this as a bug and not a feature request is because after researching how to go about this, I found a PR of what I wanted has already been merged, but doesn't seem to work. ~ #404
In PostgREST, it's possible to raise an exception with a custom message and status code which gets added to the API response. Here's an example, source
Now when you call this function using a trigger like so,
So when you try inserting a record using
supabaseClient.find('movies').insert()
, the API response comes out like,However, when you add a trigger like this to
auth.users
. It returns a generic error message "Database error saving new user".To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
auth.users
that calls this function.supabaseClient.auth.signUp()
.Expected behavior
It would be convenient if we could add a custom error message using postgres exceptions. I understand we might not want to send back every exception since that could leak information, but maybe we can have a check to see if the exception passes some criteria (ex: has certain sqlstate codes) and then pass it on to the response.
Screenshots
None
System information
Additional context
Related Issue - #271
Related Pull Request - #404
Similar Issue - supabase/storage#373
The text was updated successfully, but these errors were encountered: