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

CLI: error message is sometimes empty #32237

Closed
1 task
rix0rrr opened this issue Nov 21, 2024 · 4 comments · Fixed by #32817
Closed
1 task

CLI: error message is sometimes empty #32237

rix0rrr opened this issue Nov 21, 2024 · 4 comments · Fixed by #32817
Assignees
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI

Comments

@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 21, 2024

Describe the bug

Sometimes when we print e.message, it turns out that e is an AggregateError without a message defined itself.

In those cases, we should probably build a message out of the messages of the errors inside the AggregateError.

I'm not sure where these can originate, but the SDKv3 sometimes produces errors like this.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Framework Version

No response

Node.js Version

OS

Language

TypeScript

Language Version

No response

Other information

No response

@rix0rrr rix0rrr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 21, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Nov 21, 2024
@ashishdhingra ashishdhingra added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 21, 2024
@ashishdhingra
Copy link
Contributor

Labeling this as p2 since this is opened by CDK team.

@mrgrain
Copy link
Contributor

mrgrain commented Dec 5, 2024

Adding to Programmatic Toolkit work since we are touching this anyway.

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Dec 11, 2024

See also #32481

sumupitchayan added a commit that referenced this issue Jan 13, 2025
…32817)

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
- [x] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*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 <[email protected]>
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
iankhou pushed a commit that referenced this issue Jan 13, 2025
…32817)

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
- [x] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*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 <[email protected]>
mrgrain pushed a commit that referenced this issue Jan 14, 2025
…32817)

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
- [x] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*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 <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants