-
Notifications
You must be signed in to change notification settings - Fork 39
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
Make raise_400_for_marshmallow_errors
raise again
#317
Merged
airstandley
merged 1 commit into
plangrid:master
from
kaiku:gkuwaye/make-raise-400-for-marshmallow-errors-raise-again
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If there's no errors this function should just return. That is what it was previously doing before this bug was introduced.
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.
I think keeping this change actually makes things better.
This function is designed around
marshmallow.ValidationError
. I think that if we handle aValidationError
and this function is called with the props of the validation error, it should raise aBadRequest
. Intuitively, by naming, and practically, thinking about a web request, this makes sense.Instead, we have a case where if
errs
is empty/falsy, we don't do anything. The only caller in flask-rebar is_get_data_or_400
that passeserrs=e.messages_dict
where e is aValidationError
. The marshmallow src will raise aTypeError
if the underlyingmessages
prop isn't a dict. In real world use of validating request payloads, I haven't seen this error, which tells me that it is practically speaking nearly or always set as a dict when raised as the result ofcompat.load
.I think this is a case where introducing a bit of breakage in service of correctness is OK. WDYT?
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.
I'm sold, as long as we document in the release notes that this is a bugfix where previously errors were not raised, it's a small enough change I'm on board with making it as a correction.