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

Gracefully handle the case when additionSchema targets an invalid shape #1708

Merged
merged 2 commits into from
Apr 1, 2023

Conversation

sugmanue
Copy link
Contributor

@sugmanue sugmanue commented Apr 1, 2023

Description of changes:

Update the logic that gets process the shape of the additionalSchema property to avoid attempting to dereference a non-structure shape. Without this the Optional::get throws and exception when the shape is not an structure and hides out the actual error.

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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@sugmanue sugmanue requested a review from a team as a code owner April 1, 2023 01:26
@@ -150,11 +150,12 @@ public CfnResourceIndex(Model model) {
// setting, but gracefully handle if they're not.
model.getShape(additionalSchema)
.map(Shape::asStructureShape)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this just be a flatMap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, updated.

@sugmanue sugmanue merged commit 2378099 into smithy-lang:main Apr 1, 2023
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