-
-
Notifications
You must be signed in to change notification settings - Fork 708
fix: zod boolean coercion should correctly parse "true" and "false" #2049
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
base: main
Are you sure you want to change the base?
Conversation
|
WalkthroughA custom Zod schema type, Changes
Sequence Diagram(s)sequenceDiagram
participant EnvVarInput as Env Var Input
participant CoercedBoolean as CoercedBoolean Schema
participant AppLogic as Application Logic
EnvVarInput->>CoercedBoolean: Provide input ("true", "false", true, false)
CoercedBoolean->>CoercedBoolean: Coerce value to boolean
CoercedBoolean-->>AppLogic: Return correct boolean (true/false)
AppLogic->>AppLogic: Use coerced value in logic
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
🧰 Additional context used🧬 Code Graph Analysis (5)apps/webapp/app/utils/zod.ts (1)
apps/supervisor/src/env.ts (1)
apps/supervisor/src/envUtil.ts (1)
apps/webapp/app/components/runs/v3/RunFilters.tsx (1)
apps/webapp/app/env.server.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms (6)
🔇 Additional comments (9)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Closes #✅ Checklist
Testing
I was trying to setup SMTP with my self-hosted trigger.dev instance, and I kept running into the following error:
After some debugging I realised it was because
SMTP_SECURE=false
orSMTP_SECURE="false"
both get parsed byz.coerce.boolean()
astrue
. The only way to succesfully get this to work, without this patch, is to completely omit theSMTP_SECURE
variable such that the result isundefined
(presumably) thanks to the.optional()
modifier on the field.https://zod.dev/?id=coercion-for-primitives

The fix I propose for this is the
CoercedBoolean
zod util I added, which accepts either a boolean or a string"true"
or"false"
. We could also expand this to accept"1"
and"0"
but considering I couldn't see a use of this in the docs, I omitted it here.This could be considered breaking, if someone was relying on the previous behaviour of any non-empty string equalling
true
.Zod Playground
Changelog
fix: zod boolean coercion should correctly parse "true" and "false"
Summary by CodeRabbit