-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Inconsistent behavior in passing request fields to Schema.load (many=True vs many=False) #268
Comments
@tuukkamustonen is this fixed in webargs 6 beta? |
Fixed. from werkzeug.exceptions import UnprocessableEntity
from marshmallow import Schema, fields
from webargs.flaskparser import FlaskParser
from unittest.mock import Mock
class Foo(Schema):
foo = fields.Str()
parser = FlaskParser()
req = Mock()
req.mimetype = 'application/json'
req.get_data = lambda *args, **kwargs: '[{"extra": 1}]'
# Both raise UnprocessableEntity
try:
parser.parse(Foo(many=True), req=req, location='json')
except UnprocessableEntity:
print('OK')
try:
parser.parse(Foo(), req=req, location='json')
except UnprocessableEntity:
print('OK') |
This indeed looks like fixed now. Thanks for checking! |
Just a minor "correction": The latter case, with But both those now raise error properly, so yeah it's fixed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With
4.0.0
(and marshmallow3.0.0b13
):So the with
many=True
the extra key is actually passed toSchema.load()
(which can then raiseValidationError
becauseunknown
defaults toRAISE
) but withmany=False
it is passed onwards. I think it's confusing.#267 would fix this.
The text was updated successfully, but these errors were encountered: