-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(integ-tests): use transformToString
on API call response
#27122
Conversation
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
packages/@aws-cdk/integ-tests-alpha/lib/assertions/providers/lambda-handler/sdk.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/integ-tests-alpha/lib/assertions/providers/lambda-handler/sdk.ts
Outdated
Show resolved
Hide resolved
For anyone looking at this, i'll take over the PR now and address my own comments :) |
...-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-substitution.ts
Outdated
Show resolved
Hide resolved
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.
Can you add unit tests for coerceResponse
?
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). |
transformToString
on API call response
…7122) This PR fixes an issue where our assertions handler will fail when logging the response of an API call if the response body is a Blob. Specifically, the following error is thrown: ``` Converting circular structure to JSON --> starting at object with constructor 'TLSSocket' | property 'parser' -> object with constructor 'HTTPParser' --- property 'socket' closes the circle (RequestId: 50c1b6cd-47d2-494f-baf1-d22646cd4e5f) ``` The fix for this issue was to call the `transformToString` method on the response body. This is mentioned in aws-sdk-js-v3 [`UPGRADE.md`](https://github.com/aws/aws-sdk-js-v3/blob/main/UPGRADING.md?plain=1#L573-L576) as the solution for `Lambda::Invoke`. Its unclear why `S3::GetObject` isn't mentioned as well, but it works for that too. However, instead of explicitly extracting the `Body` property from a response, we now recursively traverse the response and detect any such blob types that should be converted to strings - this should protect us against any other APIs that may exhibit this behavior. > `transformToString` is implemented as part of the [`SdkStreamMixin` interface](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-smithy-types/Interface/SdkStreamMixin/). Included in this PR is a fix for `aws-s3-deployment/test/integ.bucket-deployment-substitution.ts` which was previously failing with the error shown above. Co-authored by: @iliapolo Co-authored by: @vinayak-kukreja Co-authored by: @scanlonp Closes #27114 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@colifran I'm getting the following when running integration tests in
This is directly after the following log line:
|
Hey @msambol, That's worrying. Can you go into a bit of detail what test is triggering this problem? |
@rix0rrr / @colifran I went back to
Different error than I originally got but I think related? Still digging. |
@msambol FYI you can pass It's possible this has broken one of the existing tests, 'cause you are absolutely right: They don't get automatically re-run for changes to If the response body is too large, we will have to set output paths to limit the response. |
Happy to submit a PR with some guidance. |
This PR fixes an issue where our assertions handler will fail when logging the response of an API call if the response body is a Blob. Specifically, the following error is thrown:
The fix for this issue was to call the
transformToString
method on the response body. This is mentioned in aws-sdk-js-v3UPGRADE.md
as the solution forLambda::Invoke
. Its unclear whyS3::GetObject
isn't mentioned as well, but it works for that too.However, instead of explicitly extracting the
Body
property from a response, we now recursively traverse the response and detect any such blob types that should be converted to strings - this should protect us against any other APIs that may exhibit this behavior.Included in this PR is a fix for
aws-s3-deployment/test/integ.bucket-deployment-substitution.ts
which was previously failing with the error shown above.Co-authored by: @iliapolo
Co-authored by: @vinayak-kukreja
Co-authored by: @scanlonp
Closes #27114
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license