Skip to content

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

@lukesmmr

Description

@lukesmmr

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 👍🏽

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions