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

feat(validation): shared interface to notify user of all validation issues when initializing a new RDS DB Cluster or SQS Queue #32841

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

Conversation

iankhou
Copy link
Contributor

@iankhou iankhou commented Jan 10, 2025

Issue #32840

Closes #32840

Reason for this change

When initializing a new RDS DB Cluster, the current implementation fails on the first validation error, making it possible for the user to encounter another failure after fixing known validation issues.

The same holds true for new SQS Queue props validation.

Description of changes

Implemented a validation function that collects all validation errors and presents them to the user.

Describe any new or updated permissions being added

No permissions changes.

Description of how you validated changes

Added unit tests and modified existing unit tests.

Screenshot 2025-01-16 at 14 51 47

Checklist


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

@iankhou iankhou self-assigned this Jan 10, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team January 10, 2025 19:07
@github-actions github-actions bot added feature-request A feature should be added or improved. p2 labels Jan 10, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 10, 2025
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.

@@ -2093,30 +2172,6 @@ describe('cluster', () => {
});
});

test('throws if performanceInsightRetention is set but performance insights is disabled', () => {
Copy link
Contributor Author

@iankhou iankhou Jan 10, 2025

Choose a reason for hiding this comment

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

These two tests did the same thing (as implemented), removed them here and moved to line 567.

}).toThrow('Aurora Limitless Database requires I/O optimized storage type, got: aurora');
});

test.each([[], undefined])('throw error for invalid cloudwatch log exports', (cloudwatchLogsExports) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested at line 584.

@iankhou iankhou changed the title test refactor to notify user of all validation issues when initializi… feature(rds): test refactor to notify user of all validation issues when initializing a new RDS DB Cluster Jan 10, 2025
@iankhou iankhou changed the title feature(rds): test refactor to notify user of all validation issues when initializing a new RDS DB Cluster test(rds): test refactor to notify user of all validation issues when initializing a new RDS DB Cluster Jan 10, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 10, 2025 19:21

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

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 81.45%. Comparing base (9d8a7e2) to head (098a5b2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #32841      +/-   ##
==========================================
- Coverage   81.48%   81.45%   -0.04%     
==========================================
  Files         226      227       +1     
  Lines       13768    13776       +8     
  Branches     2416     2417       +1     
==========================================
+ Hits        11219    11221       +2     
- Misses       2271     2277       +6     
  Partials      278      278              
Flag Coverage Δ
suite.unit 81.45% <25.00%> (-0.04%) ⬇️

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

Components Coverage Δ
packages/aws-cdk 80.89% <ø> (ø)
packages/aws-cdk-lib/core 82.03% <25.00%> (-0.07%) ⬇️

@iankhou iankhou marked this pull request as ready for review January 11, 2025 01:37
@github-actions github-actions bot added the effort/small Small work item – less than a day of effort label Jan 11, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 11, 2025
@iankhou iankhou changed the title test(rds): test refactor to notify user of all validation issues when initializing a new RDS DB Cluster test(rds): refactor to notify user of all validation issues when initializing a new RDS DB Cluster Jan 11, 2025
@iankhou iankhou changed the title test(rds): refactor to notify user of all validation issues when initializing a new RDS DB Cluster feat(rds): refactor to notify user of all validation issues when initializing a new RDS DB Cluster Jan 13, 2025
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.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 13, 2025
@iankhou
Copy link
Contributor Author

iankhou commented Jan 13, 2025

Exemption Request: unit test changes provide coverage for single and multiple errors returned, no README changes are needed as the effects of this change will be intuitive to users.

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-maintainer-review This PR needs a review from a Core Team Member labels Jan 13, 2025
Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

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

Two pieces of feedback:

  • Can you please change this to use ValidationError? We are currently starting a migration of all error types to the new ValidationError. You could not have known that. But would be good to get started on it.
  • This is great progress towards a more generic validation system. Good stuff! However I think we already should be aiming much higher and make this a generic (private) feature in core, so that all our constructs can you use this.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 13, 2025
@iankhou
Copy link
Contributor Author

iankhou commented Jan 13, 2025

@mrgrain

Two pieces of feedback:

  • Can you please change this to use ValidationError? We are currently starting a migration of all error types to the new ValidationError. You could not have known that. But would be good to get started on it.
  • This is great progress towards a more generic validation system. Good stuff! However I think we already should be aiming much higher and make this a generic (private) feature in core, so that all our constructs can you use this.

First one is an easy change and I will implement this.

For your second point, are you suggesting to generalize validateDatabaseClusterProps to validateProps, and to take in a set of validation rules? In my current PR's implementation, the rules are generated using another function createDatabaseClusterValidationRules, but I suppose this could be made into createValidationRules and take in a set of conditions + messages?

But I worry this might be too abstracted. We have different rules for standard and limitless database initializations, and offering flexibility in an abstraction might make a generalized function more difficult to use. Happy to hear your thoughts on this.

@mrgrain
Copy link
Contributor

mrgrain commented Jan 13, 2025

For your second point, are you suggesting to generalize validateDatabaseClusterProps to validateProps, and to take in a set of validation rules? In my current PR's implementation, the rules are generated using another function createDatabaseClusterValidationRules, but I suppose this could be made into createValidationRules and take in a set of conditions + messages?

If I understand the PR correctly, you are introducing a feature that allows a construct to declare a number if rules that can be validated independently from each other. If any of the rules fails, the construct will throw a validation error with all failing rules.

I think this a feature that would benefit other constructs as well and is worth generalizing.

But I worry this might be too abstracted. We have different rules for standard and limitless database initializations, and offering flexibility in an abstraction might make a generalized function more difficult to use. Happy to hear your thoughts on this.

That's a good concern, and we will have to make sure the API is easy enough to understand. I agree, this PR feels complex because you are starting from the list of all possible rules and then run some filters to only pick the applicable ones. That part I think can be kept local to the RDS DB Cluster.

…is interface for SQS and RDS props validation.
@iankhou iankhou force-pushed the iankhou-rds-test-refactor branch from 8aef9e4 to 16787f0 Compare January 16, 2025 19:13
@iankhou iankhou requested a review from a team as a code owner January 16, 2025 19:13
@iankhou iankhou changed the title feat(rds): refactor to notify user of all validation issues when initializing a new RDS DB Cluster feat(rds + sqs): refactor to notify user of all validation issues when initializing a new RDS DB Cluster or SQS Queue Jan 16, 2025
@iankhou iankhou changed the title feat(rds + sqs): refactor to notify user of all validation issues when initializing a new RDS DB Cluster or SQS Queue feat(rds,sqs): refactor to notify user of all validation issues when initializing a new RDS DB Cluster or SQS Queue Jan 16, 2025
@iankhou iankhou changed the title feat(rds,sqs): refactor to notify user of all validation issues when initializing a new RDS DB Cluster or SQS Queue feat(validation): shared interface to notify user of all validation issues when initializing a new RDS DB Cluster or SQS Queue Jan 16, 2025
@aws-cdk-automation
Copy link
Collaborator

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-rds): props validation for new DB cluster should include all validation errors at once
3 participants