{"record":{"id":"9ef8fc831ec0e093","repo":"sveltejs/kit","slug":"keypath-should-be-a-number-if-specified","errorCode":null,"errorMessage":"${keypath} should be a number, if specified","messagePattern":"(.+?) should be a number, if specified","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":456,"sourceCode":" */\nfunction string_array(fallback) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tif (!Array.isArray(input) || input.some((value) => typeof value !== 'string')) {\n\t\t\tthrow new Error(`${keypath} must be an array of strings, if specified`);\n\t\t}\n\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {number} fallback\n * @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","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L438-L474","documentation":"The `number` validator throws when a numeric config option receives a value that is not of type 'number'. Numeric settings such as `kit.prerender.concurrency` or `kit.prerender.pages` limits must be actual numbers; strings read from env vars or config files frequently fail this check.","triggerScenarios":"Setting kit.prerender.concurrency: '4' (string from process.env) or concurrency: null, then running validate_options during build/dev.","commonSituations":"Passing env-var strings (process.env.CONCURRENCY) directly into numeric options, or JSON-parsed values that arrived as strings.","solutions":["Coerce with Number(): kit: { prerender: { concurrency: Number(process.env.CONCURRENCY) } }.","Provide a literal number in the config instead of a quoted value.","Remove the key to use the documented fallback."],"exampleFix":"// before\nkit: { prerender: { concurrency: process.env.CONCURRENCY } } // '4'\n// after\nkit: { prerender: { concurrency: Number(process.env.CONCURRENCY) || 1 } }","handlingStrategy":"type-guard","validationCode":"const c = cfg.kit?.prerender?.concurrency;\nif (c !== undefined && typeof c !== 'number') throw new Error(`concurrency should be a number, got ${typeof c}`);","typeGuard":"function isNumberOrUndefined(v) { return v === undefined || (typeof v === 'number' && !Number.isNaN(v)); }","tryCatchPattern":"try {\n  validateOptions(cfg);\n} catch (e) {\n  if (String(e.message).includes('should be a number')) {\n    console.error('Numeric option got non-number:', e.message, '— coerce env values with Number()');\n    process.exit(1);\n  } else throw e;\n}","preventionTips":["Always Number()-coerce numeric values from env vars or CLI flags.","Never quote numeric literals in svelte.config.js.","Check typeof in any code that builds the config dynamically."],"tags":["sveltekit","config-validation","type-error","number"],"backgroundTag":"config-type-mismatch","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}