Skip to content

Conversation

@Lukanite
Copy link
Contributor

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

Issue # (if applicable)

Closes #36052.

Reason for this change

Can't create a Source.jsonData() when null values are present in the JSON data itself

Description of changes

Added a null check around escapeTokens() to prevent it from trying to process null values

Describe 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

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`
@github-actions github-actions bot added the bug This issue is a bug. label Nov 14, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team November 14, 2025 03:59
@github-actions github-actions bot added p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Nov 14, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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)

@Lukanite Lukanite changed the title fix(cdk-lib): S3 deployment fails on jsonData with null values fix(s3-deployment): Source.jsonData creation fails with null JSON values Nov 14, 2025
@Lukanite Lukanite changed the title fix(s3-deployment): Source.jsonData creation fails with null JSON values fix(s3-deployment): Source.jsonData creation fails with null JSON values Nov 14, 2025
@Lukanite Lukanite changed the title fix(s3-deployment): Source.jsonData creation fails with null JSON values fix(s3-deployment): Source.jsonData() fails with null JSON values Nov 14, 2025
@Lukanite
Copy link
Contributor Author

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!

@aws-cdk-automation aws-cdk-automation dismissed their stale review November 14, 2025 09:42

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

}

if (typeof obj === 'object') {
if (obj !== null && typeof obj === 'object') {
Copy link
Member

@Abogical Abogical Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mergify
Copy link
Contributor

mergify bot commented Nov 14, 2025

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).

@mergify
Copy link
Contributor

mergify bot commented Nov 14, 2025

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).

@mergify mergify bot merged commit 67b85f2 into aws:main Nov 14, 2025
19 of 20 checks passed
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2025
@leonmk-aws
Copy link
Contributor

Thank you @Lukanite for reporting the issue and fixing it so quickly !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws-s3-deployment: Can't upload JSON Data with null values

4 participants