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

Error is an empty object #381

Open
alexkreidler opened this issue Dec 17, 2022 · 4 comments
Open

Error is an empty object #381

alexkreidler opened this issue Dec 17, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@alexkreidler
Copy link

Bug report

I'm making a request like this:

const res = await postgrest.from('surveys').select('*').eq('id', 'abc')
console.log(res)

The HTTP request to the relevant URL (localhost:5001/surveys?id=eq.abc&select=*) returns a 404 status code and this JSON:

{"code":"22P02","details":null,"hint":null,"message":"invalid input syntax for type uuid: \"abc\""}

Describe the bug

When I print res, res.error is an empty object, instead of the expected object containing the JSON response data.

Screenshots

image

System information

  • OS: windows
  • Browser: chrome
  • Version of postgrest-js: v1.1.1
@alexkreidler alexkreidler added the bug Something isn't working label Dec 17, 2022
@soedirgo
Copy link
Member

soedirgo commented Jan 6, 2023

The screenshot seems to say that error contains something - can you click the dropdown button there?

Also wrt the invalid input syntax error, can you make sure that you're querying the right table and that id has the type you expect? See also: #376 (comment)

@alexkreidler
Copy link
Author

Sorry for my late response.

image

As you can see, that's simply Chrome DevTools' representation of an empty object. And yes I am querying the right table, but purposefully with a bad string id "abc" for the reproducibility of this bug. If you try writing any error-inducing code with library that results in a PostgREST-level error, unfortunately the library will not return it to the user. This is a pretty critical issue for me.

@soedirgo
Copy link
Member

soedirgo commented Apr 18, 2023

Ah got it, so the issue is the error from PostgREST isn't being populated on the error field - the invalid UUID format in the example is intentional. Can you see if it helps to update the library version? If not, can you put up a repo so I can reproduce this? We have tests on the error response so it's odd that this happens.

@jcerjak
Copy link

jcerjak commented Dec 14, 2023

@soedirgo here is a failing test which shows the issue for insert(): jcerjak@9d8b90d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants