You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
payload build requires runtime secrets because it loads the full config (Payload 3 & 4) #18497
payload build imports payload.config.ts in full before it runs the framework build. It does this through runtime.getConfig(): first to load the CLI commands, then for generateImportMap and generateTypes.
A config that validates its environment when it is imported therefore breaks the build in CI. Examples are throwing on a missing PAYLOAD_SECRET or DATABASE_URL, or on any value the app requires. In CI, runtime secrets are deliberately absent. The framework build that follows (vite build on TanStack Start) never evaluates the config, so only the generate step needs it.
Today there are two workarounds, and neither is good:
Placeholder values in the build environment. Every required variable needs a fake value, only so the config can load.
A config that detects it is being built. Build-specific branches end up in production code.
The build-time steps (import map, types) can run without runtime configuration. Some options:
A documented, supported way to build without runtime values, for example:
the CLI loads the config in a mode where secret and db aren't required, or
buildConfig takes them lazily, so they are only read when Payload initialises.
A flag such as payload build --skip-generate that runs only the framework build, so the generated files can come from a separate step that has the secrets, or be committed.
update: not only payload build, but every CLI command.
The CLI imports the full config while it starts up (createCLIRuntime → getConfig(), called from loadCLICommands), before any command is chosen. I updated the reproduction repo, which now shows:
without .env, all of these fail with Missing runtime configuration: PAYLOAD_SECRET, DATABASE_URL:
So --skip-generate alone wouldn't fix it. A CI job that only checks whether the committed importMap.js is up to date (generate:importmap + diff) needs placeholder secrets too. Commands that open a database (migrate*) clearly need real values. Commands that only read the config's structure (import map, types, help) shouldn't.
Activity
Llois41 commentedon Oct 5, 2026
update: not only
payload build, but every CLI command.The CLI imports the full config while it starts up (
createCLIRuntime→getConfig(), called fromloadCLICommands), before any command is chosen. I updated the reproduction repo, which now shows:without
.env, all of these fail withMissing runtime configuration: PAYLOAD_SECRET, DATABASE_URL:So
--skip-generatealone wouldn't fix it. A CI job that only checks whether the committedimportMap.jsis up to date (generate:importmap+ diff) needs placeholder secrets too. Commands that open a database (migrate*) clearly need real values. Commands that only read the config's structure (import map, types, help) shouldn't.