Skip to content

Fix raising exception on multiple schemas - #119

Open
tnguyenhv wants to merge 1 commit into
apryor6:masterfrom
tnguyenhv:query-schema-fix
Open

Fix raising exception on multiple schemas#119
tnguyenhv wants to merge 1 commit into
apryor6:masterfrom
tnguyenhv:query-schema-fix

Conversation

@tnguyenhv

@tnguyenhv tnguyenhv commented Mar 15, 2023

Copy link
Copy Markdown

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
Copy Markdown

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.

2 participants