-
Notifications
You must be signed in to change notification settings - Fork 37
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
Improve error messages from FromMultipart #36
Improve error messages from FromMultipart #36
Conversation
8.0 and 8.2 builds failed due to |
Thanks! Good error messages are useful. I will take a look at this soon.
I personally think supporting everything down to 8.0 is not too much to ask. As long as we don't have any evidence that nobody cares, I wouldn't touch it. Anyway that would be a different PR, no? |
Okay, I've reverted that small change, now it should build on 8.0. I have another thought: do we really need the " |
The extra prefix could be helpful, depending on how unhelpful the parser is, which depends on the user of the library, so I'm not sure we should depend on it. Would |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice! Since it's a breaking change, I would like a second opinion, but I'd be happy to release this. Thanks @maksbotan!
@@ -246,10 +258,10 @@ class FromMultipart tag a where | |||
-- in a list of textual inputs and another list for | |||
-- files, try to extract a value of type @a@. When | |||
-- extraction fails, servant errors out with status code 400. | |||
fromMultipart :: MultipartData tag -> Maybe a | |||
fromMultipart :: MultipartData tag -> Either String a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are ways to make this change easier for the library users, but I'm not sure it should be. Perhaps it's good to force everybody to take a look at this if they can't somehow produce a useful error here; if not, it's still straight-forward enough to do something like maybe (Left "no error info, sorry") Right
to the maybe-parser.
Yes, I think it should be a breaking change. @arianvp, @dmjio anybody: any opinions?
Since the PR is such an obvious improvement either way: if you feel strongly about this and nobody else objects, I'm ok with the change you suggest. |
Hi, I'm okay with extended message hiding Re breaking changes: I believe there is no need in transition mechanism, let users see this right away and be able to react. Anyway I suppose this will go into major version bump, like 0.12.0. Re nitpicks: I'll also react to them in a commit today :) Thanks for the review! |
This allows users of the library to provide more fine-grained error messages for their FromMultipart instances.
0e10ee4
to
0d0f2a7
Compare
I've rebased the history to make it pretty and incorporated your ideas. Thanks! Just in case: after this is merged, I'm going to make a PR with regenerated haskell-ci and another one with version bump. |
Some users may want to process parsing errors in their handlers instead of relying on servant-multipart's default error response. So we introduce Lenient mode similar to Capture.
This test suite checks that all modes of decoding work as expected, without running full warp web server. Previous test-suite "upload" was converted to an executable, since it is useless as a test-suite.
0d0f2a7
to
1d7c091
Compare
Ping? :) |
i'll try to give this a quick look tomorrow. if I don't then Matthias just should merge this I think |
Thanks again, and sorry for the delay! Not sure about when we'll make a release. Probably not before zurihac. |
Thanks! |
Hi,
I've tried using
servant-multipart
and observed that error messages from parsing are not very informative. Therefore I decided to introduce Lenient mode, analogous to Capture.