-
Notifications
You must be signed in to change notification settings - Fork 413
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
Bug: APIGatewayRestResolver(enable_validation=True) is validating middleware responses #5228
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
For others experiencing the issue that, like me, was dependent on this behaviour to go from SQLAlchemy objects to JSON without really knowing the internals of pydantic, here is the workaround
If my example above adding an assumed ORM object
|
Hey @ob1-dev! Thanks for reporting this! I'm able to reproduce the behavior here and I'm going to check the code to see what is going on. |
Just a quick update: I’ll be focusing on this issue this week and will provide some updates soon. |
Hello everyone! I'm in the last phase of testing the solution because I had to change the middleware execution flow a little. This is extremely critical I'm testing several possibilities so as not to break anyone that is already using Middleware and Data validation together. |
@leandrodamascena, what is the status of this? The original report is less about middleware processing and more about using the What is not evident to developers is that adding the flag causes middleware to be added, and it will ALWAYS be the first middleware, so it feels like a bug, and request/response handling is not working. This is duplicated by #4656. Need to be careful about how to fix this - I like the suggestion of #4656 - also the documentation does not make it clear about how this works - That Validation failure will short-circuit the request/response cycle and not actually run your handler or middleware at all! |
Expected Behaviour
Given the documentation, I would have expected the Validation to be skipped in the situation a middleware responds before the request gets to the route handler.
Current Behaviour
Current behaviour is that my error handler captures a the raise in the OpenAPI validation
Code snippet
Possible Solution
Perhaps the support of the Union of responses from an endpoint, or in the event a request doesn't make it to the route that Validation isn't performed.
Steps to Reproduce
template.yml
pyproject.toml
Preparing the requirements.txt
SAM Build and Local Start-API
Browse to localhost
Hitting specifically
http://localhost:3000/test
will now trigger the validation errorPowertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.12
Packaging format used
Lambda Layers
Debugging logs
The text was updated successfully, but these errors were encountered: