-
Notifications
You must be signed in to change notification settings - Fork 153
fix(parser): fix cause errors nested structure #3250
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing the issue and for the PR, Alex.
I have left a minor comment in one of the envelope files, but it's not a blocking one. Feel free to merge as-is if you prefer to leave it.
|
Summary
This PR fixes the bug of nested errors inside the
ParsedResultError
structure.Changes
In the generic
Envelope
we have returned aParsedResultError
structureIn all cases the
Envelope
was called from specific envelopes such asApiGateway
,EventBridge
etc. and in all of such cases we repackage the entire response again, which causeserror.cause
to beParseError
(from the Envelope call), and the not the expectedZodError
.Therefore, the
Envelope.safeParse
now returns a generic error or whatever we catch within thesafeParse
and nooriginalEvent
. The reason for that is that the specific envelope has the entire original payload and should have the responsibility to return this information back to the user. At that point theoriginalEvent
is not relevant for theEnvelope
object at all.I had to modify the return because TypeScript is not aware of the if-statement before the return:
I have also added more specific error assertions in the tests.
Issue number: closes #3208
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.