-
Notifications
You must be signed in to change notification settings - Fork 48
Validate resource model if type mismatch #274
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
Merged
wbingli
merged 2 commits into
aws-cloudformation:master
from
wbingli:validate_type_mismatch
Jun 8, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
45 changes: 45 additions & 0 deletions
45
...est/java/software/amazon/cloudformation/data/create.request.with-invalid-model-types.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"awsAccountId": "123456789012", | ||
"bearerToken": "123456", | ||
"region": "us-east-1", | ||
"action": "CREATE", | ||
"responseEndpoint": "https://cloudformation.us-west-2.amazonaws.com", | ||
"resourceType": "AWS::Test::TestModel", | ||
"resourceTypeVersion": "1.0", | ||
"requestContext": {}, | ||
"requestData": { | ||
"callerCredentials": { | ||
"accessKeyId": "IASAYK835GAIFHAHEI23", | ||
"secretAccessKey": "66iOGPN5LnpZorcLr8Kh25u8AbjHVllv5/poh2O0", | ||
"sessionToken": "lameHS2vQOknSHWhdFYTxm2eJc1JMn9YBNI4nV4mXue945KPL6DHfW8EsUQT5zwssYEC1NvYP9yD6Y5s5lKR3chflOHPFsIe6eqg" | ||
}, | ||
"platformCredentials": { | ||
"accessKeyId": "32IEHAHFIAG538KYASAI", | ||
"secretAccessKey": "0O2hop/5vllVHjbA8u52hK8rLcroZpnL5NPGOi66", | ||
"sessionToken": "gqe6eIsFPHOlfhc3RKl5s5Y6Dy9PYvN1CEYsswz5TQUsE8WfHD6LPK549euXm4Vn4INBY9nMJ1cJe2mxTYFdhWHSnkOQv2SHemal" | ||
}, | ||
"providerCredentials": { | ||
"accessKeyId": "HDI0745692Y45IUTYR78", | ||
"secretAccessKey": "4976TUYVI234/5GW87ERYG823RF87GY9EIUH452I3", | ||
"sessionToken": "842HYOFIQAEUDF78R8T7IU43HSADYGIFHBJSDHFA87SDF9PYvN1CEYASDUYFT5TQ97YASIHUDFAIUEYRISDKJHFAYSUDTFSDFADS" | ||
}, | ||
"providerLogGroupName": "providerLoggingGroupName", | ||
"logicalResourceId": "myBucket", | ||
"resourceProperties": { | ||
"property1": [ | ||
"list-instead-of-string" | ||
], | ||
"property2": 123 | ||
}, | ||
"systemTags": { | ||
"aws:cloudformation:stack-id": "SampleStack" | ||
}, | ||
"stackTags": { | ||
"tag1": "abc" | ||
}, | ||
"previousStackTags": { | ||
"tag1": "def" | ||
} | ||
}, | ||
"stackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/SampleStack/e722ae60-fe62-11e8-9a0e-0ae8cc519968" | ||
} |
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.
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.
What happens to exceptions thrown here, if the JSON payload is completely malformed and doesn't contain the fields you're expecting?
Uh oh!
There was an error while loading. Please reload this page.
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.
The JSON payload completely malformed only if it invoked not by CloudFormation, which this case is really unlikely, or someone debug with local
sam
.The above
this.serializer.deserialize(input, typeReference)
will throw different exception if the payload is malformed, it won't be catched byMismatchedInputException
. We have unit test to cover the malformed input (0 bytes or invalid json), those passed as expected.The only case I can think that
rawInput.getJSONObject("requestData").getJSONObject("resourceProperties");
isnull
or malformedrequestData
, the whole payloadHandlerRequest
hasMismatchedInputException
in other fields. However, I don't think it's case we need to worry about.