{"record":{"id":"23129cc6ec0bb80b","repo":"sveltejs/kit","slug":"keypath-must-be-an-array-of-strings-if-specifi","errorCode":null,"errorMessage":"${keypath} must be an array of strings, if specified","messagePattern":"(.+?) must be an array of strings, if specified","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":442,"sourceCode":"\treturn validate(fallback, (input, keypath) => {\n\t\tassert_string(input, keypath);\n\n\t\tif (!allow_empty && input === '') {\n\t\t\tthrow new Error(`${keypath} cannot be empty`);\n\t\t}\n\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {string[] | undefined} [fallback]\n * @returns {Validator}\n */\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}","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L424-L460","documentation":"The `string_array` validator requires that, when an option is provided, its value is an array containing only strings. It is used for list-shaped kit options (e.g. `kit.alias`-adjacent lists, CSP-like directives lists, `moduleExtensions` style options). Passing anything else — or an array with mixed types — throws this error.","triggerScenarios":"Assigning a single string instead of an array (e.g. someOption: '*.example.com'), or an array containing non-strings (numbers, booleans, null), to any option validated by string_array in options.js.","commonSituations":"Hand-editing config and forgetting array brackets, or building lists programmatically where undefined/null entries sneak in from optional lookups.","solutions":["Wrap the value in an array: someOption: ['*.example.com'].","Filter or coerce array members to strings before assigning.","Omit the option (leave undefined) if you don't need it — the error only fires when it is specified."],"exampleFix":"// before\nkit: { csp: { styleSrc: 'self' } }\n// after\nkit: { csp: { styleSrc: ['self'] } }","handlingStrategy":"type-guard","validationCode":"const v = cfg.kit?.csp?.styleSrc;\nif (v !== undefined && !(Array.isArray(v) && v.every((x) => typeof x === 'string'))) {\n  throw new Error('csp.styleSrc must be an array of strings');\n}","typeGuard":"function isStringArrayOrUndefined(v) { return v === undefined || (Array.isArray(v) && v.every((x) => typeof x === 'string')); }","tryCatchPattern":"try {\n  validateOptions(cfg);\n} catch (e) {\n  if (String(e.message).includes('must be an array of strings, if specified')) {\n    console.error('List-shaped option has wrong type:', e.message);\n    process.exit(1);\n  } else throw e;\n}","preventionTips":["Wrap single values in arrays when writing list options.","Filter null/undefined from programmatically built lists.","Keep svelte.config.js type-checked with JSDoc or TS."],"tags":["sveltekit","config-validation","type-error","array"],"backgroundTag":"schema-validation-failed","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}