Skip to content

fix(env): parse boolean flags instead of coercing them - #1245

Open
emanuelbenavile wants to merge 1 commit into
Merit-Systems:mainfrom
emanuelbenavile:fix/env-boolean-flags
Open

emanuelbenavile wants to merge 1 commit into
Merit-Systems:mainfrom
emanuelbenavile:fix/env-boolean-flags

Conversation

@emanuelbenavile

Copy link
Copy Markdown

REDIS_DISABLE and HIDE_TRPC_LOGS use z.coerce.boolean(), which runs Boolean(value). Any non-empty string becomes true, so:

  • REDIS_DISABLE=false disables Redis
  • HIDE_TRPC_LOGS=false hides tRPC logs

The cache benchmark in #1196 ran into this: its REDIS_DISABLE override had to be an empty string to mean "enabled".

This switches both to z.stringbool() from Zod 4, which accepts true/false, 1/0, yes/no, on/off, y/n and enabled/disabled, case insensitive.

Unchanged: an unset or empty variable still falls back to the current default, because createEnv runs with emptyStringAsUndefined: true.

Behavior change: a value outside that list, such as REDIS_DISABLE=maybe, now fails env validation at boot instead of silently meaning true.

Checked: pnpm check passes (format, oxlint, knip, publish check, and types for every package) except @x402scan/app types, which fail on current main without this change: src/app/(app)/(home)/resources/register/_components/form.tsx(930,23): Type 'string' is not assignable to type 'UrlObject | RouteImpl<string>'.

🤖 Generated with Claude Code

z.coerce.boolean() runs Boolean(value), so any non-empty string is true:
REDIS_DISABLE=false disables Redis and HIDE_TRPC_LOGS=false hides tRPC
logs. z.stringbool() reads true/false, 1/0, yes/no, on/off, y/n and
enabled/disabled, case insensitive. Unset or empty values keep their
current defaults because createEnv runs with emptyStringAsUndefined.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@EmanuXBe is attempting to deploy a commit to the Merit Systems Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant