Skip to content

feat(event_handler): allow customers to catch request validation errors #3396

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

Merged
merged 8 commits into from
Nov 22, 2023

Conversation

rubenfonseca
Copy link
Contributor

Issue number: #3395

Summary

Changes

Please provide a summary of what's being changed

This PR allows the exception handler feature to work again when using data validation.

User experience

Please share what the user experience looks like before and after this change

app = APIGatewayRestResolver(enable_validation=True)

@app.exception_handler(RequestValidationError)
def handle_invalid_data(ex: RequestValidationError):
    return Response(
        status_code=422,
        content_type=content_types.TEXT_PLAIN,
        body="Invalid request parameters.",
    )

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 22, 2023
@rubenfonseca rubenfonseca force-pushed the rf/validation_exception_handler branch from c169812 to 3b5132e Compare November 22, 2023 15:02
@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 22, 2023
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 22, 2023
@rubenfonseca rubenfonseca linked an issue Nov 22, 2023 that may be closed by this pull request
@rubenfonseca rubenfonseca self-assigned this Nov 22, 2023
@rubenfonseca rubenfonseca added this to the OpenAPI in Event Handler milestone Nov 22, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (270060d) 95.39% compared to head (6ca9fb1) 95.41%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3396      +/-   ##
===========================================
+ Coverage    95.39%   95.41%   +0.02%     
===========================================
  Files          208      208              
  Lines         9645     9645              
  Branches      1767     1768       +1     
===========================================
+ Hits          9201     9203       +2     
+ Misses         330      329       -1     
+ Partials       114      113       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rubenfonseca rubenfonseca marked this pull request as ready for review November 22, 2023 15:23
@rubenfonseca rubenfonseca requested a review from a team November 22, 2023 15:23
@heitorlessa heitorlessa changed the title chore(event_handler): enable exception handler when using validation feat(event_handler): enable exception handler when using validation Nov 22, 2023
@heitorlessa heitorlessa changed the title feat(event_handler): enable exception handler when using validation feat(event_handler): allow customers to catch request validation errors Nov 22, 2023
@heitorlessa heitorlessa merged commit 481905e into develop Nov 22, 2023
@heitorlessa heitorlessa deleted the rf/validation_exception_handler branch November 22, 2023 15:38
@heitorlessa heitorlessa added the feature New feature or functionality label Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event_handlers feature New feature or functionality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Exception handling doesn't work with data validation
3 participants