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

Merged
merged 3 commits into from
Dec 10, 2024
Merged

fix: bigint coerce crash #3822

merged 3 commits into from
Dec 10, 2024

Conversation

kodemon
Copy link
Contributor

@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 644af27
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/674351829b7e130008299459
😎 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.

@kodemon kodemon requested a review from hdsuperman November 24, 2024 16:18
@kodemon kodemon marked this pull request as ready for review November 24, 2024 16:18
@colinhacks
Copy link
Owner

Love it, thanks!

@colinhacks colinhacks merged commit 1d0a4b9 into colinhacks:main Dec 10, 2024
4 checks passed
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
3 participants