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

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

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

@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
@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 60.00000% with 18 lines in your changes missing coverage. Please review.

Project coverage is 81.52%. Comparing base (f63ec29) to head (ded7a14).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #32817      +/-   ##
==========================================
- Coverage   81.52%   81.52%   -0.01%     
==========================================
  Files         222      223       +1     
  Lines       13717    13740      +23     
  Branches     2417     2420       +3     
==========================================
+ Hits        11183    11201      +18     
- Misses       2254     2257       +3     
- Partials      280      282       +2     
Flag Coverage Δ
suite.unit 81.52% <60.00%> (-0.01%) ⬇️

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

Components Coverage Δ
packages/aws-cdk 80.97% <60.00%> (-0.01%) ⬇️
packages/aws-cdk-lib/core 82.09% <ø> (ø)

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

The pull request linter fails with the following errors:

❌ CLI code has changed. A maintainer must run the code through the testing pipeline (git fetch origin pull/32817/head && git push -f origin FETCH_HEAD:test-main-pipeline), then add the 'pr-linter/cli-integ-tested' label when the pipeline succeeds.

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.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 477425d
  • 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 join this conversation on GitHub. Already have an account? Sign in to comment
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/needs-cli-test-run This PR needs CLI tests run against it. 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