t3-oss / t3-env

https://env.t3.gg
MIT License
2.78k stars 86 forks source link

Default values skipped when using SKIP_ENV_VALIDATION #266

Open iFlyinq opened 2 months ago

iFlyinq commented 2 months ago

Description

When using SKIP_ENV_VALIDATION=true with @t3-oss/env-nextjs, the entire Zod validation process is skipped. This is useful for scenarios like Docker builds, but it introduces an unexpected side effect: default values specified in the Zod schema are not applied.

This behavior can lead to undefined environment variables where default values were expected, potentially causing buildtime errors or unexpected behavior in the application.

Current Behavior

  1. When SKIP_ENV_VALIDATION=true, all Zod validations are bypassed.
  2. Default values specified in the Zod schema (e.g., .default("development")) are not applied.
  3. Environment variables without a value remain undefined instead of using their specified defaults.

Expected Behavior

Even when skipping full validation:

  1. Default values specified in the Zod schema should be applied.
  2. Basic type coercion (e.g., z.coerce.number()) should still occur.
  3. The application should be able to run with a minimal set of required environment variables.