-
Notifications
You must be signed in to change notification settings - Fork 154
ParseError no longer use the error.cause property #2773
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hi @tusharf5, thank you for opening this issue. You are right in that the The idea was to use the "native" property instead of one defined by us, however it seems that I introduced a bug by not propagating the second argument we pass when we throw a class ParseError extends Error {
public constructor(message: string, options?: { cause?: Error }) {
const errorMessage = options?.cause
? `${message}. This error was caused by: ${options?.cause.message}.`
: message;
- super(errorMessage);
+ super(errorMessage, options);
this.name = 'ParseError';
}
} Even though the API for this specific utility is still to be considered unstable during its beta period, we should have included this property in our tests. -- Thank you for submitting the PR to fix it, I've left a couple comments. Once addressed it's good to be merged. |
This issue is now closed. Please be mindful that future comments are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so. |
Hi @tusharf5, the release notes are not yet out but we made a release that includes the fix to this issue. This should unblock your production workload. Thanks again for the quick PR. |
This is now released under v2.5.0 version! |
Expected Behavior
Earlier the error thrown within the handler would be attached to the ParseError to the .cause property. This no longer is the case. This broke one of our prod services that were relying on this property.
I think it was unintentionally removed as part of dropping Node 16 support.
Here's the link to the change.
e4eee73#diff-27fac689aa83bd57991ab46c30f4cd72584c529baa433ce899e8b7bd6db7a7deL21
Current Behavior
ParseError.cause is undefined
Code snippet
Just throw any validation error in the handler and look for error.cause property.
Steps to Reproduce
You can run any tests in this file "packages/parser/tests/unit/envelope.test.ts" and check for error.cause property. It will be undefined.
Possible Solution
I've submitted a PR which reverts the ParseError change that removed this behaviour.
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs
No response
The text was updated successfully, but these errors were encountered: