{"record":{"id":"fa206ef5a6b8292e","repo":"sveltejs/kit","slug":"invalid-route-id-id","errorCode":null,"errorMessage":"Invalid route ID ${id}","messagePattern":"Invalid route ID (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/sync/create_manifest_data/sort.js","lineNumber":51,"sourceCode":"\t\t/** @type {Part[]} */\n\t\tconst parts = [];\n\n\t\tlet i = 0;\n\t\twhile (i <= id.length) {\n\t\t\tconst start = id.indexOf('[', i);\n\t\t\tif (start === -1) {\n\t\t\t\tparts.push({ type: 'static', content: id.slice(i), matched: false });\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tparts.push({ type: 'static', content: id.slice(i, start), matched: false });\n\n\t\t\tconst type = id[start + 1] === '[' ? 'optional' : id[start + 1] === '.' ? 'rest' : 'required';\n\t\t\tconst delimiter = type === 'optional' ? ']]' : ']';\n\t\t\tconst end = id.indexOf(delimiter, start);\n\n\t\t\tif (end === -1) {\n\t\t\t\tthrow new Error(`Invalid route ID ${id}`);\n\t\t\t}\n\n\t\t\tconst content = id.slice(start, (i = end + delimiter.length));\n\n\t\t\tparts.push({\n\t\t\t\ttype,\n\t\t\t\tcontent,\n\t\t\t\tmatched: content.includes('=')\n\t\t\t});\n\t\t}\n\n\t\treturn parts;\n\t}\n\n\treturn routes.sort((route_a, route_b) => {\n\t\tconst segments_a = split_route_id(route_a.id).map(get_parts);\n\t\tconst segments_b = split_route_id(route_b.id).map(get_parts);\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/sync/create_manifest_data/sort.js#L33-L69","documentation":"While splitting a route ID into segments, SvelteKit encounters a `[` (or `[[`/`[...`) parameter whose closing delimiter (`]` or `]]`) is missing. This means the route directory/file name has an unbalanced bracket, e.g. src/routes/blog[[category. The manifest generator cannot parse the route and throws during `svelte-kit sync`.","triggerScenarios":"A route id containing `[` with no matching `]` or `]]` — e.g. creating the directory src/routes/items[page (missing closing bracket) or a partially-deleted optional parameter [[lang folder.","commonSituations":"Manually renaming route folders and deleting the closing bracket; shell commands that mangle brackets; merge conflicts leaving half-renamed directories; filesystems or tools that strip/escape brackets.","solutions":["Open the route path reported in the error and add the missing closing bracket: [param] , [[optional]] , or [...rest].","If the parameter is no longer wanted, rename the directory to remove the bracket entirely.","Re-run `svelte-kit sync` (or restart dev server) after fixing to regenerate the manifest."],"exampleFix":"// before\nsrc/routes/blog/[[category/src/routes/blog/[[category]\n// after\nsrc/routes/blog/[[category]]/","handlingStrategy":"validation","validationCode":"function hasBalancedRouteBrackets(routeId) {\n  let i = 0;\n  while ((i = routeId.indexOf('[', i)) !== -1) {\n    const optional = routeId[i + 1] === '[';\n    const delim = optional ? ']]' : ']';\n    if (routeId.indexOf(delim, i) === -1) return false;\n    i += 1;\n  }\n  return true;\n}\n// assert(hasBalancedRouteBrackets('blog/[[category]]'))","typeGuard":"function isValidRouteId(id) {\n  return typeof id === 'string' && [...id.matchAll(/\\[/g)].every((m) => id.slice(m.index).includes(id[m.index + 1] === '[' ? ']]' : ']'));\n}","tryCatchPattern":"try {\n  const parts = split(routeId);\n} catch (e) {\n  if (e.message.startsWith('Invalid route ID')) {\n    console.error('Fix unbalanced brackets in:', routeId);\n  }\n  throw e;\n}","preventionTips":["Create parameter directories via editor/CLI templates rather than manual shell commands.","Check for unbalanced brackets after merge conflicts in src/routes.","Run svelte-kit sync (or dev server) immediately after route renames to catch parse errors early."],"tags":["sveltekit","routing","route-parameters","syntax"],"backgroundTag":"invalid-route-id","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}