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(aws-cdk-lib): allow create explicitly empty trees on aws-cdk-lib core #29217

Closed
wants to merge 3 commits into from

Conversation

Rondineli
Copy link

Issue # (if applicable)

Closes #29165.

Reason for this change

Using addOverride calls deepMerge, and few edge cases like wafv2 rules needs Actions and other keys with objects and empty objects.

Description of changes

Changing the code to be more realistic with the comment, where only null data is deleted

Description of how you validated changes

No tests, just making sure the current change would be compatible with current tests, should not break anything

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 labels Feb 22, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team February 22, 2024 10:58
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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.

@Rondineli Rondineli changed the title fix(aws-cdk-lib) - Allow create explicitly empty trees on aws-cdk-lib core fix(aws-cdk-lib): Allow create explicitly empty trees on aws-cdk-lib core Feb 22, 2024
@Rondineli Rondineli changed the title fix(aws-cdk-lib): Allow create explicitly empty trees on aws-cdk-lib core fix(aws-cdk-lib): allow create explicitly empty trees on aws-cdk-lib core Feb 22, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 22, 2024 20:17

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@Rondineli Rondineli marked this pull request as ready for review February 22, 2024 20:19
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@paddy-bedraggled
Copy link

+1 request for this change

@jeffersonfrazer
Copy link

+1

1 similar comment
@fshermann
Copy link

+1

Copy link
Contributor

@paulhcsun paulhcsun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, also you may need to rerun the integ tests locally with --update-on-failed and push any changes as the snapshots in the PR may not reflect your latest changes which might explain why it's failing.

@@ -654,7 +664,6 @@ function deepMerge(target: any, ...sources: any[]) {
if (key === '__proto__' || key === 'constructor') {
continue;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add back the linebreak here

Comment on lines +643 to +644
// Availabe wafv2 empty objects
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-wafv2-webacl-ruleaction.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Availabe wafv2 empty objects
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-wafv2-webacl-ruleaction.html
/**
* Availabe WAFv2 empty objects
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-wafv2-webacl-ruleaction.html
*/

@@ -640,6 +640,16 @@ const MERGE_EXCLUDE_KEYS: string[] = [
'Fn::Or',
];

// Availabe wafv2 empty objects
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is vague and doesn't explain what these are used for, nor how "empty objects" relates to DELETE_MERGE_EXCLUDE_KEYS. Maybe provide a short snippet of context, you can reference the description for MERGE_EXCLUDE_KEYS on line 617

@@ -541,6 +541,44 @@ describe('resource', () => {
});
});

test('addOverride(p, {object: {object: {}}}) will respect empty trees', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer different wording like support over respect here

@@ -725,7 +734,20 @@ function deepMerge(target: any, ...sources: any[]) {
// sibling concrete values alongside, so we can delete this tree.
const output = target[key];
if (typeof(output) === 'object' && Object.keys(output).length === 0) {
delete target[key];
/*
* some empty trees are needed in some edge cases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* some empty trees are needed in some edge cases
* Some empty trees are needed in some edge cases

Comment on lines +738 to +739
* some empty trees are needed in some edge cases
* ie: wafv2 Rules (for Action, OverrideAction, etc...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clarify which some empty trees and maybe combine the ie into the some edge cases like ... are needed when WAFv2 rule action is one of 'Action', 'Block', 'Captcha', 'Challenge' or 'Count'.

@udaypant udaypant linked an issue Mar 11, 2024 that may be closed by this pull request
@paulhcsun
Copy link
Contributor

paulhcsun commented Mar 12, 2024

@Rondineli I have some concerns about this change breaking existing customers even behind a feature flag. Please have a look at the comments on the original issue.

@aws-cdk-automation
Copy link
Collaborator

This PR has been in the BUILD FAILING state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@Rondineli
Copy link
Author

@Rondineli I have some concerns about this change breaking existing customers even behind a feature flag. Please have a look at the comments on the original issue.

Sorry, but I really dont get the backwards compatibility bit? As I am explicitly setting the keys to it ignore. And trust me, I tried the way it is right now and cloudformation broke because those missing keys on waf rules, so, my guess is if someone tried to use it, it did not work.

I would be happy to change the PR for another approach, but this is definitely something broken and wont cause regression, quite the opposite.

@aws-cdk-automation
Copy link
Collaborator

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wafv2: add_override does not obey Action key
6 participants