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

Differentiate between PostgREST and PostgreSQL errors in the error body #1917

Closed
laurenceisla opened this issue Aug 17, 2021 · 1 comment · Fixed by #1926
Closed

Differentiate between PostgREST and PostgreSQL errors in the error body #1917

laurenceisla opened this issue Aug 17, 2021 · 1 comment · Fixed by #1926
Assignees
Labels
enhancement a feature, ready for implementation

Comments

@laurenceisla
Copy link
Member

laurenceisla commented Aug 17, 2021

Issue

I think the error body that the user gets does not clearly disambiguate if they come from the PostgreSQL database or from PostgREST itself. One way to know the difference is that the code key and its value are not present for PostgREST errors.

Proposals

  1. A source string could be prepended to the PostgREST error message, while leaving the PostgreSQL errors untouched:
{
  "message": "PostgREST: Could not find...",
  "hint": "...."
}
  1. Take the unused code key value pairs and specify that it's a PostgREST error there, leaving the rest untouched:
{
  "code": "PostgREST",
  "message": "Could not find...",
  "hint": "..."
}

Maybe use unique codes like PostgREST101 or PGRST101 to identify each error.

@laurenceisla laurenceisla added the idea Needs of discussion to become an enhancement, not ready for implementation label Aug 17, 2021
@steve-chavez
Copy link
Member

Sounds like a good idea. It will even make more sense when #1710 (comment) is implemented.

  1. A source string could be prepended to the PostgREST error message, while leaving the PostgreSQL erros untouched
  2. Take the unused code key value pairs and specify that it's a PostgREST error there, leaving the rest untouched

I'd go with 2, the current error message might be used by some client libraries and we could break them.

Maybe use unique codes like PostgREST101 or PGRST101 to identify each error.

Hm, right now I don't see the need for using codes(and seems more work to think about them), it would be good to go with just "PostgREST" as the code.


Implementing this will also let us document our error message body in the docs since it will be more stable.

@steve-chavez steve-chavez added the enhancement a feature, ready for implementation label Aug 18, 2021
@laurenceisla laurenceisla self-assigned this Aug 23, 2021
@wolfgangwalther wolfgangwalther removed the idea Needs of discussion to become an enhancement, not ready for implementation label Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a feature, ready for implementation
Development

Successfully merging a pull request may close this issue.

3 participants