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

Merged

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

Sorry, something went wrong.

@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;

nmussy added 3 commits June 10, 2024 16:18
@@ -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 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.

GavinZZ
GavinZZ previously approved these changes Feb 6, 2025
Copy link
Contributor

mergify bot commented Feb 6, 2025

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-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Feb 6, 2025
Copy link
Contributor

mergify bot commented Feb 6, 2025

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).

@mergify mergify bot dismissed GavinZZ’s stale review February 7, 2025 19:39

Pull request has been modified.

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.83%. Comparing base (7067c89) to head (00945ad).

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           
Flag Coverage Δ
suite.unit 80.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 79.56% <ø> (ø)
packages/aws-cdk-lib/core 82.20% <ø> (ø)

Copy link
Contributor

mergify bot commented Feb 7, 2025

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).

@mergify mergify bot merged commit 4744ee5 into aws:main Feb 7, 2025
20 checks passed
Copy link
Contributor

mergify bot commented Feb 7, 2025

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link

github-actions bot commented Feb 7, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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