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

feature: bubble up specific publicly accessible Postgres error messages #404

Merged
merged 7 commits into from
Jun 6, 2022

Conversation

bnjmnt4n
Copy link
Contributor

What kind of change does this PR introduce?

Feature.

What is the current behavior?

Exceptions raised in Postgres when interacting with the database are not bubbled up to the endpoints, leaving the endpoints returning more generic error messages. See #271.

What is the new behavior?

If an error is returned, which either is a plain raise exception "message" call, or has a format like https://postgrest.org/en/v9.0/api.html#raise-errors-with-http-status-codes, the error message and related information will be passed up to the endpoint. This occurs for both the JSON endpoints, and for the OAuth redirect for error messages.

All other Postgres error types are considered internal and will not be exposed.

Additional context

Closes #271.

@silentworks
Copy link

I can confirm that this PR fixes issue #271

Copy link
Member

@kangmingtay kangmingtay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bnjmnt4n, sry this took awhile to review but as @silentworks mentioned, we've tested it out on before / after triggers and it bubbles up the error successfully! :) One thing to note is that if the trigger doesn't raise an exception and fails because of some other reason (e.g. integrity constraint violations) then gotrue still returns an internal server error (500).

I'm leaning towards bubbling up the error returned from the trigger if it is due to an integrity constraint violation. Let me know what you think?

utilities/postgres.go Outdated Show resolved Hide resolved
utilities/postgres.go Show resolved Hide resolved
utilities/postgres.go Show resolved Hide resolved
utilities/postgres.go Show resolved Hide resolved
@kangmingtay kangmingtay merged commit 8ef6798 into supabase:master Jun 6, 2022
@kangmingtay
Copy link
Member

hey @bnjmnt4n, thanks for your contribution to resolve this issue once again! I'm gonna push ahead with some of these changes and get it in first - feel free to follow up with an issue if you think any additional error codes should be included.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2022

🎉 This PR is included in version 2.6.34 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow exception created by a user inside of a trigger function to bubble up when using signUp/signIn
3 participants