-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(s3-deployment): Source.jsonData() fails with null JSON values
#36054
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
Conversation
In cdk-lib aws-s3-deployment, creating a Source.jsonData() will fail if the JSON has any null fields in it due to `escapeTokens` trying to build an object from it, resulting in `TypeError: Cannot convert undefined or null to object`
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 review is outdated)
Source.jsonData creation fails with null JSON values
Source.jsonData creation fails with null JSON valuesSource.jsonData() fails with null JSON values
|
Thanks @pahud for kicking off the PR build, I'm committing these changes from another machine that isn't set up yet. I see the style errors, will address and update the commit shortly! |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
| } | ||
|
|
||
| if (typeof obj === 'object') { | ||
| if (obj !== null && typeof obj === 'object') { |
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.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |
|
Thank you @Lukanite for reporting the issue and fixing it so quickly ! |
In cdk-lib aws-s3-deployment, creating a Source.jsonData() will fail if the JSON has any null fields in it due to
escapeTokenstrying to build an object from it, resulting inTypeError: Cannot convert undefined or null to objectIssue # (if applicable)
Closes #36052.
Reason for this change
Can't create a Source.jsonData() when
nullvalues are present in the JSON data itselfDescription of changes
Added a null check around
escapeTokens()to prevent it from trying to processnullvaluesDescribe any new or updated permissions being added
N/A
Description of how you validated changes
Tested by hand via modifying the compiled JS in my project to add the check, and was able to successfully upload a JSON file to S3 with a null value contained inside. Also added coverage via unit tests/integration tests for the PR build to chew through.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license