haskell-servant / haskell-servant/servant
Provide option to disable aeson decoding error messages
- Dominant language
- Haskell
- Stars
- 2k
- Forks
- 427
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 5
Description
When sending an invalid json payload, the backend sends this message back:
```
Error in $: When parsing the record Person of type Lib.Person the key name was not present.
```
This exposes server internals, which I find is weird to have as default behaviour.
To workaround this, someone suggested this as a solution, which is to use ``Lenient`` in my routes:
```haskell
ReqBody' '[Lenient] '[JSON] a
```
And then within my handler, I'd take in the following parameter:
```haskell
Either String a
```
While this works, it looks really ugly to have to mark every route with ``Lenient``, and every handler with ``Either String a``.
Of course, I could always write a convenience function & type to wrap over it, but is there a better solution to this?
Contributor guide
Assessment
This issue has not been assessed yet.