chore(ir): add specific error message when an invalid resource property is used#594
Merged
cdklabs-automation merged 8 commits intomainfrom Mar 5, 2024
Merged
Conversation
Signed-off-by: Francis <colifran@amazon.com>
property_type is used
added 7 commits
March 5, 2024 10:03
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Codecov Report
Additional details and impacted files
@@ Coverage Diff @@
## main #594 +/- ##
=======================================
+ Coverage 81.0% 81.2% +0.2%
=======================================
Files 27 27
Lines 5098 5110 +12
Branches 5098 5110 +12
=======================================
+ Hits 4130 4148 +18
+ Misses 766 761 -5
+ Partials 202 201 -1
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Contributor
|
Could we wordsmith that error a little more? Maybe some thing more like: |
Contributor
|
Neverminddddd, that part of the error message is on the CLI side so approving this since it looks great! |
TheRealAmazonKendra
approved these changes
Mar 5, 2024
1 task
mergify bot
pushed a commit
to aws/aws-cdk
that referenced
this pull request
Mar 8, 2024
### Reason for this change This change is a follow-up to a [PR](cdklabs/cdk-from-cfn#594) that improved the error message thrown by `cdk-from-cfn` when an invalid resource property was used in a CloudFormation template. This PR further improves the error message on the cli side. ### Description of changes Primarily, this PR is a verbiage change. The base error message now states that the `<stack-name> could not be generated because <error-message>`. The error message itself is checked against `unreachable` because any use of `panic!`, `unreachable!`, or `unimplemented!` will cause the `cdk-from-cfn` source code to panic in-place. In the resulting wasm binary, this produces a `RuntimeError` that has an error message of `unreachable`. I've improved this slightly by stating `template and/or language inputs caused the source code to panic`. If the error message is not `unreachable`, then the error message is taken as is with `TransmuteError:` replaced. Note that we should still continue to improve our error messages in `cdk-from-cfn` by by replacing `panic!`, `unreachable!`, and `unimplemented!` with more detailed error messages. ### Description of how you validated changes An existing unit test was changed based on the error message verbiage change. Additionally, a new unit test was added to validate that the expected error message would be thrown by the cli when an invalid resource property was used in a CloudFormation template. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the event that an invalid property is specified for a specific resource type the
value_typewill beNonecausing theotherarm of the match statement below to execute.cdk-from-cfn/src/ir/resources/mod.rs
Lines 119 to 129 in 2c14390
Due to the
unimplemented!macro panicking in-place, a non-descriptive error message is displayed while using cdk migrate:This PR adds a new explicit check for the case where
property_typeisNone. If that case is true, then a more descriptive error message will be displayed explaining what resource property is not valid. For example,By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.