{"record":{"id":"b2c67961b4b8a444","repo":"sveltejs/kit","slug":"you-should-change-envprefix-env-prefix-to-avo-b2c679","errorCode":null,"errorMessage":"You should change envPrefix (${env_prefix}) to avoid conflicts with existing environment variables — unexpectedly saw ${name}","messagePattern":"You should change envPrefix \\((.+?)\\) to avoid conflicts with existing environment variables — unexpectedly saw (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-node/src/env.js","lineNumber":28,"sourceCode":"\t'HOST_HEADER',\n\t'PORT_HEADER',\n\t'BODY_SIZE_LIMIT',\n\t'SHUTDOWN_TIMEOUT',\n\t'IDLE_TIMEOUT',\n\t'KEEP_ALIVE_TIMEOUT',\n\t'HEADERS_TIMEOUT'\n]);\n\nconst expected_unprefixed = new Set(['LISTEN_PID', 'LISTEN_FDS']);\n\nexport const env_prefix = ENV_PREFIX;\n\nif (env_prefix) {\n\tfor (const name in process.env) {\n\t\tif (name.startsWith(env_prefix)) {\n\t\t\tconst unprefixed = name.slice(env_prefix.length);\n\t\t\tif (!expected.has(unprefixed)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`You should change envPrefix (${env_prefix}) to avoid conflicts with existing environment variables — unexpectedly saw ${name}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * @param {string} name\n * @param {any} [fallback]\n */\nexport function env(name, fallback) {\n\tconst prefix = expected_unprefixed.has(name) ? '' : env_prefix;\n\tconst prefixed = prefix + name;\n\treturn prefixed in process.env ? process.env[prefixed] : fallback;\n}\n\nconst integer_regexp = /^\\d+$/;","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-node/src/env.js#L10-L46","documentation":"The node adapter validates at startup that the configured `envPrefix` does not collide with unrelated environment variables already present in `process.env`. Any variable starting with the prefix whose unprefixed name is not a known SvelteKit private env (like PRERENDER, PROTOCOL_HEADER, etc.) causes this throw, to prevent silently reading/writing unexpected variables. It protects against prefix choices like `PUBLIC_` that collide with app-level vars.","triggerScenarios":"Starting the built server with a private env var set whose name starts with envPrefix but whose unprefixed name is not in the expected set of private env variables.","commonSituations":"Configuring envPrefix as 'PUBLIC_' or a very short prefix in adapter options, then setting unrelated shell/CI variables that happen to start with it.","solutions":["Change the adapter's envPrefix option to something unique that doesn't overlap with existing env vars","Unset or rename the conflicting environment variable in the deployment environment","If the variable is a legitimate private SvelteKit env, verify the spelling of its unprefixed name matches the expected set"],"exampleFix":"// before\nconst config = { kit: { adapter: adapter({ envPrefix: 'PUBLIC_' }) } };\n// after\nconst config = { kit: { adapter: adapter({ envPrefix: 'MY_PRIVATE_' }) } };","handlingStrategy":"validation","validationCode":"const prefix = 'MY_PRIVATE_';\nconst expected = new Set(['PRERENDER', 'PROTOCOL_HEADER', 'HOST_HEADER', 'PORT_HEADER', 'BODY_SIZE_LIMIT', 'SHUTDOWN_TIMEOUT']);\nconst conflicts = Object.keys(process.env).filter(n => n.startsWith(prefix) && !expected.has(n.slice(prefix.length)));\nif (conflicts.length) throw new Error(`envPrefix conflict: ${conflicts.join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  startServer();\n} catch (err) {\n  if (String(err.message).includes('change envPrefix')) {\n    console.error('envPrefix collides with existing env vars; pick a more unique prefix');\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Pick a distinctive prefix unlikely to collide (include your app name)","Audit `env | grep ^PREFIX` in the target deployment before release","Keep the prefix long and app-scoped, not generic like PUBLIC_"],"tags":["environment","configuration","adapter-node"],"backgroundTag":"env-prefix-conflict","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}