Skip to content
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

Fix raising exception on multiple schemas #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tnguyenhv
Copy link

@tnguyenhv tnguyenhv commented Mar 15, 2023

Hello! I'm unsure of the intended behavior of this library when multiple schemas are provided for an endpoint, but I do know a KeyError occurs when one schema fails before another is processed (in my case when a failed to validate request schema precedes a successful query schema). I updated the way the errors are added onto the BadRequest by just merging the schema_errors from all the failing schemas inside of BadRequest.data['errors']['schema_errors'].

This is the error when using both request and query validation and request fails:

  File "/Users/chaz/hv/core.hivelocity.net/venv/lib/python3.8/site-packages/flask_accepts/decorators/decorators.py", line 158, in inner
    error.data["errors"].update({"schema_errors": schema_error})
KeyError: 'errors'

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (0556746) 98.44% compared to head (facfafe) 98.46%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #119      +/-   ##
==========================================
+ Coverage   98.44%   98.46%   +0.02%     
==========================================
  Files           7        7              
  Lines        1285     1303      +18     
==========================================
+ Hits         1265     1283      +18     
  Misses         20       20              
Impacted Files Coverage Δ
flask_accepts/decorators/decorators.py 98.68% <100.00%> (+0.01%) ⬆️
flask_accepts/decorators/decorators_test.py 97.53% <100.00%> (+0.05%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tnguyenhv tnguyenhv marked this pull request as ready for review March 15, 2023 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants