-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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): http flattenResponse #30361
fix(integ-tests): http flattenResponse #30361
Conversation
@nmussy any idea when this could be merged, reviewed? Can't say I am not looking forward to it? |
@kornicameister I can't give an ETA for the review and release process, but I should have the PR ready some time this week |
let resp: HttpResponseWrapper | { [key: string]: unknown }; | ||
if (request.flattenResponse === 'true') { | ||
// Flatten and explode JSON fields | ||
resp = flatten(deepParseJson({ apiCallResponse: result })); | ||
} else { | ||
// Otherwise just return the response as-is, without exploding JSON fields | ||
resp = { apiCallResponse: result }; | ||
} | ||
console.log(`Returning result ${JSON.stringify(resp)}`); |
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.
It might be worth considering a refactor of the flattenResponse
in the common CustomResourceHandler
implementation, given the SDK handler does pretty much the same thing:
aws-cdk/packages/@aws-cdk/integ-tests-alpha/lib/assertions/providers/lambda-handler/sdk.ts
Lines 18 to 22 in a2e8dc5
let resp: AwsApiCallResult | { [key: string]: unknown }; | |
if (request.outputPaths || request.flattenResponse === 'true') { | |
// Flatten and explode JSON fields | |
const flattened = flatten(deepParseJson({ apiCallResponse: response })); | |
resp = request.outputPaths ? filterKeys(flattened, request.outputPaths) : flattened; |
@@ -113,7 +113,7 @@ describe('HttpHandler', () => { | |||
const response = await processEvent({ parameters: { url: 'x' } }); | |||
|
|||
// THEN | |||
expect(response.apiCallResponse.body).toEqual({ key: 'value' }); |
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 change should not have any impact given apiCallResponse
should only be used internally, but it is caused by the type change of the HttpHandler
response from HttpResponseWrapper
to HttpResponseWrapper | { [key: string]: unknown }>
Hi This PR has been pending for community review for a while. Please consider posting it on the #contributing channel in cdk.dev. Community members will be on the lookout there as well for possible reviews. Check How to get your P2 PR community reviewed for more details. |
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). |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #30361 +/- ##
=======================================
Coverage 80.83% 80.83%
=======================================
Files 236 236
Lines 14251 14251
Branches 2490 2490
=======================================
Hits 11520 11520
Misses 2446 2446
Partials 285 285
Flags with carried forward coverage won't be shown. Click here to find out 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). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #30327
Reason for this change
There was a difference in the behavior of SDK and HTTP integration attribute extraction with the
getAtt
andgetAttString
methods.awsApiCall
properly implemented and returned JSONPath-ish values by using aflattenResponse
property. This PR adds the same functionality tohttpApiCall
Description of changes
Added an implemented
flattenResponse
in theHttpHandler
custom resourceDescription of how you validated changes
Updated integ and unit tests
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license