{"record":{"id":"7a7a7c3841ebd38b","repo":"sveltejs/kit","slug":"invalid-route-id-an-optional-route-segmen","errorCode":null,"errorMessage":"Invalid route ${id} — an [[optional]] route segment cannot follow a [...rest] route segment","messagePattern":"Invalid route (.+?) — an \\[\\[optional\\]\\] route segment cannot follow a \\[\\.\\.\\.rest\\] route segment","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/sync/create_manifest_data/index.js","lineNumber":180,"sourceCode":"\t\t\t\t\treturn String.fromCodePoint(parseInt(code, 16));\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (/\\]\\[/.test(unescaped)) {\n\t\t\t\tthrow new Error(`Invalid route ${id} — parameters must be separated`);\n\t\t\t}\n\n\t\t\tif (count_occurrences('[', id) !== count_occurrences(']', id)) {\n\t\t\t\tthrow new Error(`Invalid route ${id} — brackets are unbalanced`);\n\t\t\t}\n\n\t\t\tif (/#/.test(segment)) {\n\t\t\t\t// Vite will barf on files with # in them\n\t\t\t\tthrow new Error(`Route ${id} should be renamed to ${id.replace(/#/g, '[x+23]')}`);\n\t\t\t}\n\n\t\t\tif (/\\[\\.\\.\\.[\\w-]+\\]\\/\\[\\[/.test(id)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid route ${id} — an [[optional]] route segment cannot follow a [...rest] route segment`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (/\\[\\[\\.\\.\\./.test(id)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid route ${id} — a rest route segment is always optional, remove the outer square brackets`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst { pattern, params } = parse_route_id(id);\n\n\t\t\t/** @type {import('types').RouteData} */\n\t\t\tconst route = {\n\t\t\t\tid,\n\t\t\t\tparent,\n\n\t\t\t\tsegment,","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/sync/create_manifest_data/index.js#L162-L198","documentation":"Route ID validation error: the id matches a [...rest] parameter segment immediately followed by an [[optional]] segment (pattern [...x]/[[). Because a rest parameter already greedily matches any remaining path, an optional segment after it is ambiguous and disallowed. Fires during route manifest generation.","triggerScenarios":"Thrown at packages/kit/src/core/sync/create_manifest_data/index.js:180 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove or relocate the [[optional]] segment so it does not follow a [...rest] segment","Restructure the routes, e.g. move the optional segment before the rest parameter or into a separate route"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}