Skip to content

Conversation

mndeveci
Copy link
Contributor

Issue #, if available:
N/A

Description of changes:
Replaced ValueError exceptions with InvalidDocumentException which should help SAM Transform to gracefully exit execution for invalid Swagger/OpenAPI inputs.

Checklist:

  • Add/update unit tests using:
  • Add/update integration tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Apr 12, 2022

Codecov Report

Merging #2376 (b782ff2) into develop (e7a1496) will increase coverage by 0.78%.
The diff coverage is n/a.

@@             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     
Impacted Files Coverage Δ
samtranslator/region_configuration.py 77.77% <0.00%> (-22.23%) ⬇️
samtranslator/validator/validator.py 91.80% <0.00%> (-3.85%) ⬇️
samtranslator/model/exceptions.py 97.67% <0.00%> (-2.33%) ⬇️
samtranslator/open_api/open_api.py 89.70% <0.00%> (-2.27%) ⬇️
samtranslator/model/s3_utils/uri_parser.py 68.42% <0.00%> (-0.81%) ⬇️
samtranslator/yaml_helper.py 89.47% <0.00%> (-0.53%) ⬇️
samtranslator/model/api/api_generator.py 94.05% <0.00%> (-0.31%) ⬇️
samtranslator/translator/logical_id_generator.py 90.62% <0.00%> (-0.29%) ⬇️
samtranslator/model/apigateway.py 96.98% <0.00%> (-0.18%) ⬇️
samtranslator/intrinsics/resource_refs.py 95.83% <0.00%> (-0.17%) ⬇️
... and 43 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1a6690...b782ff2. Read the comment docs.

"""
if not OpenApiEditor.is_valid(doc):
raise ValueError(
raise InvalidDocumentException(
Copy link
Contributor

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@jfuss jfuss merged commit 9306a03 into aws:develop Apr 22, 2022
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.

4 participants