marshmallow 3 breaks the app
dlopes7 opened this issue · 5 comments
127.0.0.1 - - [24/Aug/2019 09:40:09] "POST /api/users/login HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask_jwt_extended/view_decorators.py", line 124, in wrapper
return fn(*args, **kwargs)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask_apispec/annotations.py", line 118, in wrapped
return wrapper(*args, **kwargs)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask_apispec/wrapper.py", line 32, in __call__
response = self.call_view(*args, **kwargs)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/flask_apispec/wrapper.py", line 46, in call_view
parsed = parser.parse(schema, locations=option['kwargs']['locations'])
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/webargs/core.py", line 369, in parse
result = schema.load(parsed)
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/marshmallow/schema.py", line 684, in load
data, many=many, partial=partial, unknown=unknown, postprocess=True
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/marshmallow/schema.py", line 785, in _do_load
PRE_LOAD, data, many=many, original_data=data, partial=partial
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/marshmallow/schema.py", line 1014, in _invoke_load_processors
partial=partial,
File "/home/david/projects/python/venvs/flask-realworld-example-app/lib/python3.6/site-packages/marshmallow/schema.py", line 1135, in _invoke_processors
data = processor(data, many=many, **kwargs)
TypeError: make_user() got an unexpected keyword argument 'many'
You should specify on requirements that marshmallow 2 is enforced, or update the app to be compatible with marshmallow 3
@dlopes7 I find this issue too and fix it .There is a breaking change in marshmallow 3 :
https://marshmallow.readthedocs.io/en/stable/changelog.html#rc7-2019-06-15
Backwards-incompatible: many is passed as a keyword argument to methods decorated with pre_load, post_load, pre_dump, post_dump, and validates_schema. partial is passed as a keyword argument to methods decorated with pre_load, post_load and validates_schema. **kwargs should be added to all decorated methods.
So you need to change all pre*/post* function. e.g.
#@post_dump # original one : def dump_user(self,data) def dump_user(self, data, **kwargs): return {'user': data}
@mohamed-aziz @alessandrojcm Based on issue described above , could you please accept my PR(this is only part of fix , and I will finalize more later)
@Allianzcortex I merged your PR, could you fix the code so that it passes the failed unit tests? unfortunately I have no time to work on this.
@Allianzcortex I'm not sure what the problem seems to be, take your time with this. I don't think this is related to this issue. Maybe we should open a new issue? because this was fixed by your last commit.