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

fix(integ-tests): http flattenResponse #30361

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nmussy
Copy link
Contributor

@nmussy nmussy commented May 28, 2024

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 and getAttString methods. awsApiCall properly implemented and returned JSONPath-ish values by using a flattenResponse property. This PR adds the same functionality to httpApiCall

Description of changes

Added an implemented flattenResponse in the HttpHandler custom resource

Description 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

@aws-cdk-automation aws-cdk-automation requested a review from a team May 28, 2024 15:44
@github-actions github-actions bot added bug This issue is a bug. p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels May 28, 2024
@kornicameister
Copy link
Contributor

@nmussy any idea when this could be merged, reviewed? Can't say I am not looking forward to it?

@nmussy
Copy link
Contributor Author

nmussy commented Jun 3, 2024

@kornicameister I can't give an ETA for the review and release process, but I should have the PR ready some time this week

Comment on lines +28 to +36
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)}`);
Copy link
Contributor Author

@nmussy nmussy Jun 10, 2024

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:

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' });
Copy link
Contributor Author

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 }>

@nmussy nmussy marked this pull request as ready for review June 10, 2024 14:24
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: b49c8fc
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 10, 2024
@pahud
Copy link
Contributor

pahud commented Jul 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(integ-test): HttpApiCall seems to be broken
5 participants