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: bigint coerce crash #3822

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

fix: bigint coerce crash #3822

wants to merge 2 commits into from

Conversation

kodemon
Copy link

@kodemon kodemon commented Oct 28, 2024

Discovered when parse is executed through isOptional check on ZodBigInt which adds a undefined safeParse execution to look for errors, it crashes when attempting to add undefined to BigInt as its an invalid value.

One fix here is to just try catch the instantiation and cast the coerced value to undefined if it throws and error. This way all parser checks will fail on invalid values but not crash on internal checks which provides undefined as the input value.

Perhaps another approach could be to just catch and ignore the error and let the input data checks to subsequently verify that the input value is valid. 🤔

closes #3821

Copy link

netlify bot commented Oct 28, 2024

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 4d05e52
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/672015b72b49c70008a41f86
😎 Deploy Preview https://deploy-preview-3822--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bigint with coerce throws exception in safeParse and safeParseAsync
1 participant