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(core): use correct formatting for aggregate errors in aws-cdk #32817

Merged
merged 10 commits into from
Jan 13, 2025

Conversation

sumupitchayan
Copy link
Contributor

@sumupitchayan sumupitchayan commented Jan 9, 2025

Closes #32237

Reason for this change

Sometimes when we print e.message, e is an AggegateError - so the message text is incomplete/not formatted correctly. This PR adds a new util function, formatErrorMessage which returns e.message if it exists, or a correctly formatted string of errors if e is an AggregateError.

Description of changes

See formatErrorMessage function in the newly created file, packages/aws-cdk/lib/util/error.ts. All other changes are grunt work replacing e.message with formateErrorMessage(e). This PR only does the finding and replacing in the aws-cdk package, TBD whether we need to do the same for the rest of the repo.

Describe any new or updated permissions being added

None

Description of how you validated changes

See unit tests in packages/aws-cdk/test/api/util/error.test.ts

Checklist


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

Signed-off-by: Sumu <sumughan@amazon.com>
Signed-off-by: Sumu <sumughan@amazon.com>
Signed-off-by: Sumu <sumughan@amazon.com>
@github-actions github-actions bot added the p2 label Jan 9, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team January 9, 2025 17:19
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 9, 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 added the pr/needs-cli-test-run This PR needs CLI tests run against it. label Jan 9, 2025
Signed-off-by: Sumu <sumughan@amazon.com>
@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p1 and removed p2 labels Jan 10, 2025
@sumupitchayan sumupitchayan changed the title chore: fix aggregate error message formatting fix(core): use correct formatting for aggregate errors in aws-cdk Jan 10, 2025
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 71.11111% with 13 lines in your changes missing coverage. Please review.

Project coverage is 81.41%. Comparing base (e7e908b) to head (5bb86c1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #32817      +/-   ##
==========================================
+ Coverage   81.38%   81.41%   +0.03%     
==========================================
  Files         222      223       +1     
  Lines       13698    13721      +23     
  Branches     2413     2416       +3     
==========================================
+ Hits        11148    11171      +23     
  Misses       2271     2271              
  Partials      279      279              
Flag Coverage Δ
suite.unit 81.41% <71.11%> (+0.03%) ⬆️

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

Components Coverage Δ
packages/aws-cdk 80.75% <71.11%> (+0.06%) ⬆️
packages/aws-cdk-lib/core 82.10% <ø> (ø)

@sumupitchayan sumupitchayan marked this pull request as ready for review January 10, 2025 01:23
@sumupitchayan sumupitchayan requested a review from a team as a code owner January 10, 2025 01:23
Signed-off-by: Sumu <sumughan@amazon.com>
@@ -0,0 +1,11 @@
export function formatErrorMessage(error: any): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose do add a test for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just did see packages/aws-cdk/test/api/util/error.test.ts

@sumupitchayan sumupitchayan added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Jan 10, 2025
@sumupitchayan sumupitchayan removed the pr/needs-cli-test-run This PR needs CLI tests run against it. label Jan 13, 2025
@sumupitchayan sumupitchayan added the pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested label Jan 13, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 13, 2025 15:55

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

@sumupitchayan sumupitchayan merged commit 97af31b into main Jan 13, 2025
8 of 10 checks passed
@sumupitchayan sumupitchayan deleted the sumughan/aggregate-error-handling branch January 13, 2025 15:56
Copy link

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 Jan 13, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort p1 pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: error message is sometimes empty
3 participants