-
Notifications
You must be signed in to change notification settings - Fork 153
Bug: ParsedResultError contains nested ParseErrors instead of a ParseError with a cause of ZodError #3208
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. |
Hey @marktowndrow , thanks for raising the issue. As discussed in Discord, it should be a quick fix. You also narrowed down the code and explored the solution as well. If you want, you are more than welcome to make a PR, you are half way there. We have a set of tests for parser that you can use to verify your changes. |
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. |
This is now released under v2.11.0 version! |
Expected Behavior
In the following example:
event.error.cause
should contain a ZodError, and callingevent.error.cause.errors
should return something like:Current Behavior
event.error.cause
contains a ParseError, which contains another cause which contains the ZodError.So to get to the ZodError, you have to call
event.error.cause.cause
Code snippet
POSTing the following body:
returns:
Steps to Reproduce
Create a lambda with the above code in your handler.ts
Possible Solution
I haven't tested if this affects other Envelopes as well or not, but the
apigw.ts
safeParse
function herecalls
Envelope.safeParse(...)
on line 30and then creates a new
ParseError
on line 35, with theparsedBody.error
as the cause.parsedBody.error
is itself already aParseError
from here on line 64, and that has theZodError
as its cause.So depending on whether it affects all envelopes or not, we could maybe look at changing line 64 in
envelope.ts
to beerror: parsed.error
instead of creating anew ParseError
with a cause?Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
18.x
Packaging format used
npm
Execution logs
No response
The text was updated successfully, but these errors were encountered: