Skip to content

fix(core): include extended env vars when skipValidation is true#408

Open
tmrp wants to merge 1 commit into
t3-oss:mainfrom
tmrp:fix/skip-validation-drops-extended-env
Open

fix(core): include extended env vars when skipValidation is true#408
tmrp wants to merge 1 commit into
t3-oss:mainfrom
tmrp:fix/skip-validation-drops-extended-env

Conversation

@tmrp

@tmrp tmrp commented Apr 3, 2026

Copy link
Copy Markdown

Problem

When createEnv is called with skipValidation: true, it returned runtimeEnv directly via an early return, silently dropping all variables contributed by the extends array. This meant that any preset env vars (e.g. from uploadthing() or a shared base env) were undefined at runtime whenever validation was skipped.

Fix

Hoist extendedObj above the skip guard and return Object.assign(extendedObj, runtimeEnv) instead of bare runtimeEnv. This matches the merge order of the normal validation path, so runtimeEnv values continue to take precedence over preset values.

Tests

Three regression tests added to smoke-zod4.test.ts:

  • extended env vars are accessible when skipValidation: true
  • runtimeEnv values override extended preset values (precedence preserved)
  • vars from multiple extended presets are all accessible

When `skipValidation: true`, `createEnv` was returning `runtimeEnv`
directly, silently discarding variables contributed via `extends`.

Fix by hoisting the `extendedObj` reduction above the skip guard and
merging it with `runtimeEnv` before the early return, matching the
behaviour of the normal validation path (runtimeEnv takes precedence).

Adds three regression tests in smoke-zod4.test.ts covering:
- single preset vars are accessible
- runtimeEnv values override preset values
- multiple preset vars are all accessible
@vercel

vercel Bot commented Apr 3, 2026

Copy link
Copy Markdown

@tmrp is attempting to deploy a commit to the t3-oss Team on Vercel.

A member of the Team first needs to authorize it.

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