{"record":{"id":"913f6efd8effe7b0","repo":"sveltejs/kit","slug":"keypath-should-be-true-or-false-if-specified","errorCode":null,"errorMessage":"${keypath} should be true or false, if specified","messagePattern":"(.+?) should be true or false, if specified","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":469,"sourceCode":" * @returns {Validator}\n */\nfunction number(fallback) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tif (typeof input !== 'number') {\n\t\t\tthrow new Error(`${keypath} should be a number, if specified`);\n\t\t}\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {boolean} fallback\n * @returns {Validator}\n */\nfunction boolean(fallback) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tif (typeof input !== 'boolean') {\n\t\t\tthrow new Error(`${keypath} should be true or false, if specified`);\n\t\t}\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {string[]} options\n * @returns {Validator}\n */\nfunction list(options, fallback = options[0]) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tif (!options.includes(input)) {\n\t\t\t// prettier-ignore\n\t\t\tconst msg = options.length > 2\n\t\t\t\t? `${keypath} should be one of ${options.slice(0, -1).map(input => `\"${input}\"`).join(', ')} or \"${options[options.length - 1]}\"`\n\t\t\t\t: `${keypath} should be either \"${options[0]}\" or \"${options[1]}\"`;\n\n\t\t\tthrow new Error(msg);","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L451-L487","documentation":"The `boolean` validator throws when a boolean config option receives a non-boolean value. Flags like `kit.prerender.crawl`, `kit.prerender.enabled`, or `handleHttpErrors`-style toggles must be literal true/false — truthy strings such as 'true' are rejected.","triggerScenarios":"Setting kit.prerender.crawl: 'false' (string) or crawl: 0 / crawl: null in svelte.config.js, then triggering config validation via build or dev.","commonSituations":"Boolean flags sourced from environment variables (process.env.PRERENDER is the string 'false'), or hand-edited configs quoting the value.","solutions":["Use literal true or false (unquoted) in the config.","Convert env values explicitly: crawl: process.env.PRERENDER !== 'false'.","Delete the key to use the documented default."],"exampleFix":"// before\nkit: { prerender: { crawl: 'true' } }\n// after\nkit: { prerender: { crawl: true } }","handlingStrategy":"type-guard","validationCode":"const crawl = cfg.kit?.prerender?.crawl;\nif (crawl !== undefined && typeof crawl !== 'boolean') throw new Error(`crawl should be a boolean, got ${typeof crawl}`);","typeGuard":"function isBooleanOrUndefined(v) { return v === undefined || typeof v === 'boolean'; }","tryCatchPattern":"try {\n  validateOptions(cfg);\n} catch (e) {\n  if (String(e.message).includes('should be true or false')) {\n    console.error('Boolean flag has non-boolean value:', e.message);\n    process.exit(1);\n  } else throw e;\n}","preventionTips":["Convert env flags explicitly: process.env.X !== 'false' or === 'true'.","Never quote true/false in svelte.config.js.","Prefer deriving booleans with strict comparisons, not truthiness coercion."],"tags":["sveltekit","config-validation","type-error","boolean"],"backgroundTag":"config-type-mismatch","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}