-
Notifications
You must be signed in to change notification settings - Fork 19
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
chore(ir): add specific error message when an invalid resource property is used #594
Conversation
Signed-off-by: Francis <colifran@amazon.com>
property_type
is usedSigned-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.
|
Could we wordsmith that error a little more? Maybe some thing more like: |
Neverminddddd, that part of the error message is on the CLI side so approving this since it looks great! |
### 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*
In the event that an invalid property is specified for a specific resource type the
value_type
will beNone
causing theother
arm 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_type
isNone
. 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.