Open cheizer opened 1 year ago
The error message tells you what's wrong:
The @response decorator cannot handle Response objects.
Fix your endpoint so that it returns the object referenced in the @response
decorator to address this problem. Returning a Response
object from Flask is not supported because that makes it impossible to do serialization with your Marshmallow schema.
My Schema is super simple and generic.
class BulkStateSchema(ma.Schema): data = JSON()
and my result is
return {"data": {}}, 201
@cheizer I think that is what you expect, but the error message indicates that in that particular instance a Response
object was returned instead.
Hello, How can I drill down in to the error to figure out what is going on. The API works and then all of a sudden I see this error in the logs. I'm trying to figure out if it's my code or not.
Thanks,
[2023-07-25 09:31:54 -0700] [5810] [ERROR] Error handling request /api/xstate/bulk Traceback (most recent call last): File "/opt/theFairy/env/api/lib/python3.9/site-packages/gunicorn/workers/base_async.py", line 41, in handle self.handle_request(listener_name, req, client, addr) File "/opt/theFairy/env/api/lib/python3.9/site-packages/gunicorn/workers/ggevent.py", line 127, in handle_request super().handle_request(listener_name, req, sock, addr) File "/opt/theFairy/env/api/lib/python3.9/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request respiter = self.wsgi(environ, resp.start_response) File "/opt/theFairy/env/api/lib/python3.9/site-packages/flask/app.py", line 2548, in __call__ return self.wsgi_app(environ, start_response) File "/opt/theFairy/env/api/lib/python3.9/site-packages/flask/app.py", line 2528, in wsgi_app response = self.handle_exception(e) File "/opt/theFairy/env/api/lib/python3.9/site-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/opt/theFairy/env/api/lib/python3.9/site-packages/flask/app.py", line 2525, in wsgi_app response = self.full_dispatch_request() File "/opt/theFairy/env/api/lib/python3.9/site-packages/flask/app.py", line 1822, in full_dispatch_request rv = self.handle_user_exception(e) File "/opt/theFairy/env/api/lib/python3.9/site-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/opt/theFairy/env/api/lib/python3.9/site-packages/flask/app.py", line 1820, in full_dispatch_request rv = self.dispatch_request() File "/opt/theFairy/env/api/lib/python3.9/site-packages/flask/app.py", line 1796, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "/opt/theFairy/env/api/lib/python3.9/site-packages/apifairy/decorators.py", line 96, in _response raise RuntimeError( RuntimeError: The @response decorator cannot handle Response objects.