-
Notifications
You must be signed in to change notification settings - Fork 322
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
JSON parsing with accumulative errors #578
Comments
|
In general, I think both "fail fast" and "fail with lot of info" modes are useful, but complicated to combine. For untrusted input, one should fail reasonably fast, so the service isn't easily DDOSed. |
I agree both modes have valid use cases. What I meant to say is to add another function to "fail with a lot of info." :) |
It is still possible to fail quite fast: if the first parser fails, we can return the (potential) errors of the second lazily. This would require a change in the internal |
This is something I'd like to have in aeson as well. What @Lysxia describes sounds promising!
Agreed. When it's important to fail fast in production it may still be useful to accumulate errors in development environments. circe for scala does error accumulation but it has a few kinks that make it tricky to know if errors will accumulate properly. I think it stems from the fact that they have a separate flow for accumulation, without the fail-fast behavior @Lysxia describes.
This sounds fine to me. Overall, if we can keep the monadic parser it means clients only have to update custom instances, and only if they want accumulation. PS.
This is only because |
Work on this is progressing on the |
Databrary will try to contribute in small ways to the PRs for this issue if we get time. We are hoping to make use of this. I will update this comment when we are actively trying to help. |
#683 is also related, to some extent? |
When parsing an incorrect JSON with Aeson, you only get the first error instead of all the errors like so:
It would be better to have another function to return all the errors instead of just the first one, for example:
This kind of feature would be very useful in web development where errors in request payload are all checked at once to save network round trip.
I'm thinking maybe this library can be used instead of
Either
https://hackage.haskell.org/package/Validation-0.2.0/docs/Data-Validation.htmlThe text was updated successfully, but these errors were encountered: