{"record":{"id":"32d0308db4aaf146","repo":"sveltejs/kit","slug":"keypath-should-be-a-string-if-specified","errorCode":null,"errorMessage":"${keypath} should be a string, if specified","messagePattern":"(.+?) should be a string, if specified","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":516,"sourceCode":"\treturn validate(fallback, (input, keypath) => {\n\t\tif (typeof input !== 'function') {\n\t\t\tthrow new Error(`${keypath} should be a function, if specified`);\n\t\t}\n\t\treturn input;\n\t});\n}\n\nfunction any() {\n\treturn validate(undefined, (input) => input);\n}\n\n/**\n * @param {string} input\n * @param {string} keypath\n */\nfunction assert_string(input, keypath) {\n\tif (typeof input !== 'string') {\n\t\tthrow new Error(`${keypath} should be a string, if specified`);\n\t}\n}\n","sourceCodeStart":498,"sourceCodeEnd":519,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L498-L519","documentation":"`assert_string` verifies that a config option expected to be a string is actually a string. SvelteKit throws this when a string-typed option (like an adapter name, paths option, or env dir) receives a number, boolean, object, or undefined-that-isn't-absent.","triggerScenarios":"Setting a string config option to a non-string, e.g. `paths: { base: 3000 }`, `outDir: true`, or passing a number where an appDir string is required.","commonSituations":"Copying config from docs with placeholder values not replaced; using a numeric port where a string path is expected; YAML/JSON-style config mistakes after converting to JS.","solutions":["Check the option named in the keypath in svelte.config.js.","Convert the value to a string (add quotes) or supply the correct string value.","For path-like options, ensure you didn't paste a URL or number where a path is required."],"exampleFix":"// before\npaths: { base: 3000 }\n// after\npaths: { base: '/app' }","handlingStrategy":"validation","validationCode":"const stringOptions = [['paths', 'base'], ['paths', 'assets']];\nfor (const [a, b] of stringOptions) {\n  const v = config?.kit?.[a]?.[b];\n  if (v !== undefined && typeof v !== 'string') {\n    throw new Error(`${a}.${b} must be a string, got ${typeof v}`);\n  }\n}","typeGuard":"function isString(v) {\n  return typeof v === 'string';\n}","tryCatchPattern":"try {\n  await build(config);\n} catch (e) {\n  if (String(e.message).includes('should be a string')) {\n    console.error('String config option got a non-string value:', e.message);\n  } else throw e;\n}","preventionTips":["Quote all path-like and name-like config values in svelte.config.js.","Rely on the generated Config type / editor type checking to catch wrong types.","After converting config from JSON/YAML, verify values kept their intended types."],"tags":["config","validation","types"],"backgroundTag":"invalid-config-option-value","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}