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
fix(custom-resource): custom resources fail with data containing multi-byte utf8 chars #24501
fix(custom-resource): custom resources fail with data containing multi-byte utf8 chars #24501
Conversation
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 pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
@@ -1,13 +1,4 @@ | |||
const baseConfig = require('@aws-cdk/cdk-build-tools/config/eslintrc'); | |||
baseConfig.parserOptions.project = __dirname + '/tsconfig.json'; | |||
|
|||
baseConfig.overrides = [{ | |||
// @TODO Fixing the import order will cause custom resources to updated due to a hash change | |||
// We should apply the fix the next time `framework.ts` is meaningfully changed to avoid unnecessary resource updates |
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.
Nice! Good opportunity to fix this todo 🥳
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
// THEN | ||
const emptyLength = emptyDataRequest.headers?.['content-length'] as number; | ||
const utf8Length = utf8DataRequest.headers?.['content-length'] as number; | ||
expect(utf8Length - emptyLength).toEqual(6); |
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 seems unnecessarily elaborate, but ok 😀
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.
Yep, I thought about this. But if I manually counted the bytes it is just a magic number.
f064bcc
to
df03857
Compare
@@ -54,7 +54,6 @@ | |||
"devDependencies": { | |||
"@aws-cdk/cdk-build-tools": "0.0.0", | |||
"@aws-cdk/core": "0.0.0", | |||
"@aws-cdk/integ-tests": "0.0.0", |
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 is to avoid a circular dependency with integ-tests
. It's okay because the only usage is in the language tests which are currently run manually.
Once we have the new repo structure, this should be possible to implement in the separate integ test package.
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). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
…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*
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 aResponse 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