Skip to content

Default values skipped when using SKIP_ENV_VALIDATION #266

@iFlyinq

Description

@iFlyinq

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PRs AcceptedFeel free to pick this up and make a PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions