{"record":{"id":"3068fd56d0f81e05","repo":"sveltejs/kit","slug":"keypath-cannot-be-empty","errorCode":null,"errorMessage":"${keypath} cannot be empty","messagePattern":"(.+?) cannot be empty","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":81,"sourceCode":"\t\t\t}\n\n\t\t\treturn input;\n\t\t}),\n\t\t(keypath) =>\n\t\t\t`The \\`${keypath}\\` option is deprecated, and will be removed in a future version of SvelteKit. Use subpath imports instead: https://svelte.dev/docs/kit/$lib`\n\t),\n\n\tappDir: validate('_app', (input, keypath) => {\n\t\tassert_string(input, keypath);\n\n\t\tif (input) {\n\t\t\tif (input.startsWith('/') || input.endsWith('/')) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${keypath} cannot start or end with '/'. See https://svelte.dev/docs/kit/configuration`\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(`${keypath} cannot be empty`);\n\t\t}\n\n\t\treturn input;\n\t}),\n\n\tcompilerOptions: any(),\n\n\tcsp: object({\n\t\tmode: list(['auto', 'hash', 'nonce']),\n\t\tdirectives,\n\t\treportOnly: directives\n\t}),\n\n\tcsrf: object({\n\t\tcheckOrigin: removed(\n\t\t\t(keypath) => `\\`${keypath}\\` has been removed in favour of \\`csrf.trustedOrigins\\``\n\t\t),\n\t\ttrustedOrigins: string_array([])","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L63-L99","documentation":"SvelteKit validates certain config values (like `paths.base`) must be non-empty strings. When a value that must be a non-empty string is set to an empty string, validation throws with the config key path (keypath) in the message. It exists to catch misconfigured route/path options early before build.","triggerScenarios":"Setting a config option validated by the empty-string guard (e.g. `paths.base: ''` is fine, but keys whose value must be non-empty) to `''` — specifically any string-validated keypath that is tested for emptiness and receives `''`.","commonSituations":"Copying example configs with placeholder empty values; env-driven config where an env var is unset and defaults to empty string; accidentally deleting the value in svelte.config.js.","solutions":["Set the option to a non-empty string value appropriate for the option","Remove the key entirely so SvelteKit uses its built-in default instead of an empty string","If the value comes from an env var, provide a fallback: `process.env.MY_VAR || '/default'`"],"exampleFix":"// before\nexport default {\n  paths: { base: '' }\n};\n// after\nexport default {\n  paths: { base: '/my-app' }\n};","handlingStrategy":"validation","validationCode":"const value = config.paths?.base;\nif (value !== undefined && (typeof value !== 'string' || value === '')) {\n  throw new Error('paths.base must be a non-empty string (or omitted)');\n}","typeGuard":"function isValidBase(v) {\n  return v === undefined || (typeof v === 'string' && v !== '');\n}","tryCatchPattern":"try {\n  validateConfig(config);\n} catch (e) {\n  if (String(e.message).includes('cannot be empty')) {\n    console.error('Fix empty config value in svelte.config.js');\n  }\n  throw e;\n}","preventionTips":["Never hardcode empty strings for required config options — omit the key to use defaults","Provide fallbacks when reading env vars: `process.env.X || 'default'`","Run `vite dev` or `vite build` locally before CI to surface config validation early"],"tags":["config","validation","sveltekit"],"backgroundTag":"invalid-config-value","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}