haskell-servant / haskell-servant/servant
How to check for unknown/mistyped query parameters?
- Dominant language
- Haskell
- Stars
- 2k
- Forks
- 427
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 5
Description
The current release of servant does not error out (with BadRequest or similar), if there is an unknown parameter passed. For example:
If the following example, the first API call returns sales info for a particular account in a particular country and the second API call returns sales for a particular account (across all countries).
```
GET /analyze/sales?account_id=1&country_iso=US
GET /analyze/sales?account_id=1
-- mistyped version:
GET /analyze/sales?account_id=1&country=US
```
If the country parameter is mistyped, the user gets a response (but the API returns results for the second API call above), but it is the wrong one.
With `servant` the API is neatly modelled in a handler that accepts a `Maybe AccountId` and a `Maybe CountryIso`, however, it is not possible to identify an error condition from an unknown query parameter. Is there a better way to design this API, or a workaround to this problem?
Contributor guide
Assessment
This issue has not been assessed yet.