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

V2 api - Add 4xx error handling on invalid query string parameter #27

Open
lukesmmr opened this issue Sep 15, 2021 · 0 comments
Open

V2 api - Add 4xx error handling on invalid query string parameter #27

lukesmmr opened this issue Sep 15, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@lukesmmr
Copy link

While trying the new ?concelho= query string parameter for the V2 of the api I get the same response even if the query string is invalid or does not exist. All requests return, even when adding special or random characters after the =:

{
    "success": true,
    "data": []
}

If I request https://api-dev.fogos.pt/v2/incidents/active?concelho=??? I would expect the API to resolve a failure in the 4xx error code range, since the request is semantically incorrect.

So the question is: should the API return a 4xx response informing the client that the request was invalid, or should the API perform the listing of the items as if no filter parameter was supplied? If we think of the query string parameter as a direct listing request to resources, my answer would be that requesting a resource (concelho=???) that does not exist should return a 404 or 400.

I found 2 articles on SO that support this discussion:

image

Let me know your thoughts about the ideal behaviour and what clients expect from the response. Thanks 👍🏽

@lukesmmr lukesmmr added the enhancement New feature or request label Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant