{"record":{"id":"5b05d54a68e7ed2e","repo":"sveltejs/kit","slug":"invalid-value-for-environment-variable-name","errorCode":null,"errorMessage":"Invalid value for environment variable ${name}: ${JSON.stringify(value)} (${description})","messagePattern":"Invalid value for environment variable (.+?): (.+?) \\((.+?)\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-node/src/env.js","lineNumber":56,"sourceCode":" * @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+$/;\n\n/**\n * Throw a consistently-structured parsing error for environment variables.\n * @param {string} name\n * @param {any} value\n * @param {string} description\n * @returns {never}\n */\nfunction parsing_error(name, value, description) {\n\tthrow new Error(\n\t\t`Invalid value for environment variable ${name}: ${JSON.stringify(value)} (${description})`\n\t);\n}\n\n/**\n * Check the environment for a timeout value (non-negative integer) in seconds.\n * @param {string} name\n * @param {number} [fallback]\n * @returns {number | undefined}\n */\nexport function timeout_env(name, fallback) {\n\tconst raw = env(name, fallback);\n\tif (!raw) {\n\t\treturn fallback;\n\t}\n\n\tif (!integer_regexp.test(raw)) {\n\t\tparsing_error(name, raw, 'should be a non-negative integer');","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-node/src/env.js#L38-L74","documentation":"SvelteKit adapter-node validates timeout-related environment variables (e.g. SHUTDOWN_TIMEOUT) as non-negative integers in seconds. `parsing_error` is thrown when the value cannot be parsed into the expected type/format. The message includes the raw value and a description of what was expected.","triggerScenarios":"Setting an env var consumed by timeout_env (e.g. SHUTDOWN_TIMEOUT) to a non-integer, negative number, or non-numeric string like '10s' or 'ten'.","commonSituations":"Deployment platforms exporting values with units ('30s'), whitespace, quotes, or leaving a placeholder value in the env file.","solutions":["Set the env variable to a plain non-negative integer number of seconds, e.g. 30","Remove surrounding quotes, whitespace, or unit suffixes from the value","If the value is intentionally optional, unset it entirely to use the default"],"exampleFix":"// before\nSHUTDOWN_TIMEOUT=30s\n// after\nSHUTDOWN_TIMEOUT=30","handlingStrategy":"validation","validationCode":"const v = process.env.SHUTDOWN_TIMEOUT;\nif (v !== undefined && (!/^\\d+$/.test(v.trim()))) {\n  throw new Error(`SHUTDOWN_TIMEOUT must be a non-negative integer, got: ${v}`);\n}","typeGuard":"function isValidTimeout(v) {\n  return typeof v === 'string' && /^\\d+$/.test(v.trim());\n}","tryCatchPattern":"try {\n  await server.listen(port);\n} catch (err) {\n  if (String(err.message).startsWith('Invalid value for environment variable')) {\n    console.error('Fix the offending env var to a plain integer value');\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Use plain integers (seconds) with no units in env files","Lint .env files for quoted or spaced values","Document accepted formats in your deployment README"],"tags":["environment","configuration","validation"],"backgroundTag":"invalid-env-var-value","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}