{"record":{"id":"c37edc5e8c870470","repo":"sveltejs/kit","slug":"you-should-change-envprefix-env-prefix-to-avo","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":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-bun/src/env.js","lineNumber":24,"sourceCode":"\t'HOST',\n\t'PORT',\n\t'REUSE_PORT',\n\t'IPV6_ONLY',\n\t'CONNECTION_IDLE_TIMEOUT',\n\t'BODY_SIZE_LIMIT',\n\t'SHUTDOWN_TIMEOUT',\n\t'DEVELOPMENT',\n\t'XFF_DEPTH',\n\t'ADDRESS_HEADER',\n\t'PROTOCOL_HEADER',\n\t'HOST_HEADER',\n\t'PORT_HEADER'\n]);\n\nif (env_prefix) {\n\tfor (const name in process.env) {\n\t\tif (name.startsWith(env_prefix) && !expected.has(name.slice(env_prefix.length))) {\n\t\t\tthrow new Error(\n\t\t\t\t`You should change envPrefix (${env_prefix}) to avoid conflicts with existing environment variables — unexpectedly saw ${name}`\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * @param {string} name\n * @param {string} value\n * @param {string} expected\n * @returns {never}\n */\nfunction parsing_error(name, value, expected) {\n\tthrow new Error(\n\t\t`Invalid value for environment variable ${env_prefix + name}: ${JSON.stringify(value)} (expected ${expected})`\n\t);\n}\n","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-bun/src/env.js#L6-L42","documentation":"adapter-bun lets you set an env_prefix so only variables with that prefix are exposed to the app. At startup it scans process.env and throws if a prefixed variable exists that is not one of the recognized special variables (like PORT_HEADER). This guards against accidentally leaking or misnaming environment variables that would shadow existing ones.","triggerScenarios":"Setting env_prefix to a prefix that matches variables already present in the deployment environment (e.g. envPrefix='PUBLIC_' with PUBLIC_URL set) when the variable is not consumed via env() with an expected name.","commonSituations":"Choosing a generic prefix like PUBLIC_ or APP_ that collides with host platform or CI environment variables; renaming app code without cleaning up stale prefixed variables left in the environment.","solutions":["Change the envPrefix adapter option to a more unique prefix (e.g. 'MYAPP_') so it no longer matches unrelated variables.","Remove or rename the offending environment variable from your deployment environment.","If the variable is legitimate, load it through env() so its name is in the expected set."],"exampleFix":"// before\nadapterBun({ envPrefix: 'PUBLIC_' }); // PUBLIC_URL exists in env\n// after\nadapterBun({ envPrefix: 'MYSITE_PUBLIC_' });","handlingStrategy":"validation","validationCode":"const prefix = 'MYSITE_PUBLIC_';\nconst unexpected = Object.keys(process.env).filter(\n  (k) => k.startsWith(prefix) && !['URL'].includes(k.slice(prefix.length))\n);\nif (unexpected.length) throw new Error(`Colliding env vars: ${unexpected.join(', ')}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a project-unique env prefix, not a generic one like PUBLIC_ or APP_.","Audit the deployment environment (CI, host platform) for variables matching your prefix.","Clean up stale env vars when renaming configuration keys."],"tags":["environment","configuration","adapter-bun"],"backgroundTag":"env-prefix-conflict","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}