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

Returns empty data if the queried data was not found with fields query parameter. #3176

Closed
Mr-M1M3 opened this issue Aug 23, 2023 · 2 comments

Comments

@Mr-M1M3
Copy link

Mr-M1M3 commented Aug 23, 2023

Let's say, we have a collection named users with data of type:

interface User {
   name: string;
   age: number;
}

The query

Now, I want to view only the name field of a specific record of user collection. So, I queried:

http://127.0.0.1:8090/api/collections/users/blahblah69420?fields=name

A record with id blahblah69420 doesn't exist! So, I expect pocketbase to return what it usually returns in case of a 404 not found.
However, I get no data in return.

Expected data:

{
   "code":404,
   "message":"The requested resource wasn't found.",
   "data":{}
}

Received Data

{}

NOTE

It does not happen if the field query parameter is omitted.

@ganigeorgiev
Copy link
Member

Hm, technically this is working correctly because the fields parameter is a generic way to filter/omit fields from the json response, but I could see why in this case it may not be desired as there is no way to specify upfront what fields for what response should be applied.

With the next release there are plans to add wildcard (*) support and I'll consider skipping the fields transformation for error responses.

@ganigeorgiev
Copy link
Member

I've submitted a "fix" in the develop branch that ignores the fields transformations for non 20x responses.

It will be available with the next v0.18.0 release (there is no ETA yet).

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

No branches or pull requests

2 participants