Skip to content
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

integ-tests: Response is not valid JSON #24491

Closed
nikovirtala opened this issue Mar 7, 2023 · 2 comments · Fixed by #24501
Closed

integ-tests: Response is not valid JSON #24491

nikovirtala opened this issue Mar 7, 2023 · 2 comments · Fixed by #24501
Labels
@aws-cdk/integ-tests bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Comments

@nikovirtala
Copy link
Contributor

Describe the bug

The integration test fails if the expected result object contains UTF-8 characters.

Expected Behavior

The test should return a successful status if the expectation match, regardless of what kind of data the user is trying to assert.

Current Behavior

The test fails with the following error:

 ❌  IntegTest/DefaultTest/DeployAssert failed: Error: The stack named IntegTestDefaultTestDeployAssertE3E7D2A4 failed to deploy: CREATE_FAILED (The following resource(s) failed to create: [AwsApiCallDynamoDBquery]. ): Response is not valid JSON
    at FullCloudFormationDeployment.monitorDeployment (/Users/nikovirtala/src/github.com/nikovirtala/integ-runner-proto/node_modules/aws-cdk/lib/index.js:344:10235)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async deployStack2 (/Users/nikovirtala/src/github.com/nikovirtala/integ-runner-proto/node_modules/aws-cdk/lib/index.js:347:144797)
    at async /Users/nikovirtala/src/github.com/nikovirtala/integ-runner-proto/node_modules/aws-cdk/lib/index.js:347:130251
    at async run (/Users/nikovirtala/src/github.com/nikovirtala/integ-runner-proto/node_modules/aws-cdk/lib/index.js:347:128257)

Reproduction Steps

Run the test described in: https://github.com/nikovirtala/integ-runner-proto/blob/main/test/integ.not-valid-json.ts

Possible Solution

Maybe we shouldn't send full data objects to CloudFormation? — I don't see the data being displayed to the user.

Additional Information/Context

No response

CDK CLI Version

2.66.1

Framework Version

No response

Node.js Version

v18.14.2

OS

macOS Ventura

Language

Typescript

Language Version

4.9.5

Other information

No response

@nikovirtala nikovirtala added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 7, 2023
@mrgrain
Copy link
Contributor

mrgrain commented Mar 7, 2023

Note this can be reproduced with any custom resource.

@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 7, 2023
@mergify mergify bot closed this as completed in #24501 Mar 10, 2023
mergify bot pushed a commit that referenced this issue Mar 10, 2023
…i-byte utf8 chars (#24501)

Custom Resources need to write their response into a S3 object.
This is implemented as a PUT request to a pre-signed URL and has to specify the `content-length` of the response object.
Previously the CustomResource code would use `responseBody.length`.
However this returns the number of graphemes, not bytes.
If any utf8 characters with `graphemes != bytes` are part of the response, CloudFormation would fail the deployment with a `Response is not valid JSON` error.

Also updates the `log-retention-provider` code, although the data should only contain 1-byte characters. Due to this limitation it can't be tested.

Closes #24491

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

homakk pushed a commit to homakk/aws-cdk that referenced this issue Mar 28, 2023
…i-byte utf8 chars (aws#24501)

Custom Resources need to write their response into a S3 object.
This is implemented as a PUT request to a pre-signed URL and has to specify the `content-length` of the response object.
Previously the CustomResource code would use `responseBody.length`.
However this returns the number of graphemes, not bytes.
If any utf8 characters with `graphemes != bytes` are part of the response, CloudFormation would fail the deployment with a `Response is not valid JSON` error.

Also updates the `log-retention-provider` code, although the data should only contain 1-byte characters. Due to this limitation it can't be tested.

Closes aws#24491

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/integ-tests bug This issue is a bug. effort/medium Medium work item – several days of effort p1
Projects
None yet
3 participants