-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: use InvalidDocumentException instead of ValueError #2376
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
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2376 +/- ##
===========================================
+ Coverage 93.58% 94.37% +0.78%
===========================================
Files 90 98 +8
Lines 6124 7194 +1070
Branches 1260 1482 +222
===========================================
+ Hits 5731 6789 +1058
- Misses 183 196 +13
+ Partials 210 209 -1
Continue to review full report at Codecov.
|
""" | ||
if not OpenApiEditor.is_valid(doc): | ||
raise ValueError( | ||
raise InvalidDocumentException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! We should probably do another pass and stop throwing generic python errors/exceptions.
:param dict doc: OpenApi document as a dictionary | ||
:raises ValueError: If the input OpenApi document does not meet the basic OpenApi requirements. | ||
:raises InvalidDocumentException: If the input OpenApi document does not meet the basic OpenApi requirements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be InvalidDocument or InvalidResource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can throw InvalidResource
but we need logical id of the resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. That gets me thinking but nothing specific for this PR.
Issue #, if available:
N/A
Description of changes:
Replaced
ValueError
exceptions withInvalidDocumentException
which should help SAM Transform to gracefully exit execution for invalid Swagger/OpenAPI inputs.Checklist:
make pr
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.