You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a route that has repononse_many wants to return a proper error code on a, flask-pydantic crashes with
This should return a 400 error
@app.route("/<myid>", methods=["GET"])@pydantic_validate(response_many=True)defreturn_many(myid: str):
ifnot_in_db(myid):
returnjsonify({"success": False, "message": f"{myid} not found in DB"}), 404
....
But instead, the server breaks and raises a exception:
I think this is not the right approach how to handle exceptions in Flask. I suggest you to read Error Handlers. That way you route handler just raises exception and your error handler creates JSON response with proper status code.
When a route that has
repononse_many
wants to return a proper error code on a, flask-pydantic crashes withThis should return a 400 error
But instead, the server breaks and raises a exception:
There should be some way to describe the error responses that shouldn't be a an array.
The text was updated successfully, but these errors were encountered: