-
Notifications
You must be signed in to change notification settings - Fork 48
added invalid request on invalid payload deserialization #310
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
added invalid request on invalid payload deserialization #310
Conversation
src/test/java/software/amazon/cloudformation/LambdaWrapperTest.java
Outdated
Show resolved
Hide resolved
src/main/java/software/amazon/cloudformation/LambdaWrapper.java
Outdated
Show resolved
Hide resolved
src/main/java/software/amazon/cloudformation/LambdaWrapper.java
Outdated
Show resolved
Hide resolved
src/main/java/software/amazon/cloudformation/LambdaWrapper.java
Outdated
Show resolved
Hide resolved
...st/java/software/amazon/cloudformation/data/create.request.with-extraneous-model-object.json
Outdated
Show resolved
Hide resolved
| "resourceProperties": { | ||
| "property1": "abc", | ||
| "property2": 123, | ||
| "fieldCausesValidationError": { |
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.
So the deserialization will fail if nested properties? But how the validation can successful? There is additionalProperties: false for the schema, so additional property should fail on validation.
e71b145 to
330f0c4
Compare
330f0c4 to
12435c5
Compare
wbingli
left a comment
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.
LGTM. Better to update the error message as it will be customer visible.
| this.validator.validateObject(rawModelObject, resourceSchemaJSONObject); | ||
|
|
||
| handlerResponse = ProgressEvent.defaultFailureHandler( | ||
| new CfnInvalidRequestException("Model validation failed caused by invalid input provided", e), |
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.
This message will be customer visible. Maybe better wording as "Resource properties validation failed with invalid configuration".
| "definitions": { | ||
| "subProperty": { | ||
| "type": "object", | ||
| "properties": { |
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.
All right, I think the whole problem is that the schema doesn't define "additionalProperties": false for the nest property. In such way, the deserialization to POJO fails due to this mismatch. However, validation pass as "additionalProperties": false is missing and validation will skip this additional properties.
The resource should fix the schema in such cases. But of course, this fix is still valuable.
Issue #, if available:
Description of changes:
Currently, when we hit
MismatchedInputExceptionon payload deserialization we getInternalFailure, which is not surfacing real issue to the customer; Alternatively we could put model validation upfront but then we will have strict validation on stringification; this is a good alternative as customers can see that the input is actually invalidBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.