Skip to content

fix: allow empty strings for optional config variables to prevent crash - #177

Closed
webdevsps wants to merge 1 commit into
theam:mainfrom
webdevsps:patch-1
Closed

fix: allow empty strings for optional config variables to prevent crash#177
webdevsps wants to merge 1 commit into
theam:mainfrom
webdevsps:patch-1

Conversation

@webdevsps

Copy link
Copy Markdown

What changes

By removing .min(1) from optional env variables, Zod correctly accepts empty strings instead of throwing a validation error. This allows downstream code to handle them gracefully as unconfigured.

Why

Fixes #158.
When .env contains blank entries for optional variables (like VERCEL_TOKEN), Zod strictly rejects the empty string and crashes the API server on boot.

Verification

  • pnpm verify passes locally
  • Behaviour verified beyond the test suite (verified API server boots successfully with empty VERCEL_* env vars)
  • Documentation updated, or no user-facing change

Fixes theam#158.

When `.env` contains blank entries for optional variables like `VERCEL_TOKEN`, Zod's `.min(1).optional()` validation strictly rejects the empty string and crashes the API server on boot during `npm run dev`.

By removing `.min(1)`, Zod correctly accepts empty strings, allowing downstream code (like `vercel.ts`) to handle them gracefully as unconfigured rather than crashing the entire server on boot.
@adrian-lorenzo

Copy link
Copy Markdown
Member

Thanks for the contribution!

This is already covered by #159, which treats blank values as unset and includes regression tests. This version keeps them as empty strings, so a blank VERCEL_OIDC_TOKEN can override a valid VERCEL_TOKEN. I’m closing this one in favor of #159.

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.

Fresh pnpm dev crashes the API and worker: blank VERCEL_* lines in the generated .env fail config validation

2 participants