{"record":{"id":"ac031dd23a9595de","repo":"sveltejs/kit","slug":"keypath-should-be-one-of-options-or-opt","errorCode":null,"errorMessage":"${keypath} should be one of \"${options}\" or \"${options[options.length - 1]}\"","messagePattern":"(.+?) should be one of \"(.+?)\" or \"(.+?)\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":487,"sourceCode":"\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);\n\t\t}\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {(...args: any) => any} fallback\n * @returns {Validator}\n */\nfunction fun(fallback) {\n\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","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L469-L505","documentation":"SvelteKit's config validator calls `list()` to check that a config option equals one of a fixed set of allowed values. When the value is not in the list, it throws a message enumerating every valid choice. This guards against typos and unsupported option values in svelte.config.js.","triggerScenarios":"Setting a svelte.config.js option whose validator is `list(...)` to a value outside the allowed set — e.g. `router: { type: 'hash-router' }` instead of 'hash' or 'pathname', or `csr: 'true'` (string) where only booleans are expected via list.","commonSituations":"Typo in option value; copying config from an outdated tutorial or older SvelteKit version where a value was renamed; quoting/typing mistakes like string 'true' instead of boolean true.","solutions":["Read the error message: it lists exactly the accepted values in quotes.","Replace the option value with one of the listed allowed values in svelte.config.js.","If migrating from an older SvelteKit version, check the changelog/docs for renamed option values."],"exampleFix":"// before (svelte.config.js)\nkit: { router: { type: 'hash-router' } }\n// after\nkit: { router: { type: 'hash' } }","handlingStrategy":"validation","validationCode":"const ALLOWED_ROUTER_TYPES = ['pathname', 'hash'];\nconst cfg = kit?.router?.type;\nif (cfg !== undefined && !ALLOWED_ROUTER_TYPES.includes(cfg)) {\n  throw new Error(`router.type must be one of ${ALLOWED_ROUTER_TYPES.join(', ')}, got: ${cfg}`);\n}","typeGuard":"function isRouterType(v) {\n  return v === 'pathname' || v === 'hash';\n}","tryCatchPattern":"try {\n  await dev({ config });\n} catch (e) {\n  if (String(e.message).includes('should be one of')) {\n    console.error('Invalid config option value:', e.message);\n  } else throw e;\n}","preventionTips":["Check the svelte.config.js TypeScript types (Config type) in your editor before adding options.","Copy option values only from current official docs for your installed SvelteKit version.","Run `vite build` locally after config changes to fail fast."],"tags":["config","validation","sveltekit"],"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"}