{"record":{"id":"7b7fe711b1ced7e4","repo":"withastro/astro","slug":"invalid-route-file-parameters-must-be-separat","errorCode":null,"errorMessage":"Invalid route ${file} — parameters must be separated","messagePattern":"Invalid route (.+?) — parameters must be separated","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/routing/segment.ts","lineNumber":5,"sourceCode":"export function validateSegment(segment: string, file = '') {\n\tif (!file) file = segment;\n\n\tif (segment.includes('][')) {\n\t\tthrow new Error(`Invalid route ${file} \\u2014 parameters must be separated`);\n\t}\n\tif (countOccurrences('[', segment) !== countOccurrences(']', segment)) {\n\t\tthrow new Error(`Invalid route ${file} \\u2014 brackets are unbalanced`);\n\t}\n\tif (\n\t\t(/.+\\[\\.\\.\\.[^\\]]+\\]/.test(segment) || /\\[\\.\\.\\.[^\\]]+\\].+/.test(segment)) &&\n\t\tfile.endsWith('.astro')\n\t) {\n\t\tthrow new Error(`Invalid route ${file} \\u2014 rest parameter must be a standalone segment`);\n\t}\n}\n\nfunction countOccurrences(needle: string, haystack: string) {\n\tlet count = 0;\n\tfor (const hay of haystack) {\n\t\tif (hay === needle) count += 1;\n\t}\n\treturn count;","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/routing/segment.ts#L1-L23","documentation":"validateSegment() rejected a route segment where dynamic parameters are adjacent without a separator — the pattern '][' appears inside a single segment. Astro requires parameters to be separated by static text (e.g. [id]-[lang]); back-to-back brackets like [id][lang] are ambiguous and disallowed. Thrown as a plain Error during route parsing.","triggerScenarios":"A filename like src/pages/[id][lang].astro; multiple params jammed into one segment with no separating characters; copy-paste errors concatenating param brackets.","commonSituations":"Trying to combine two params in one segment; misunderstanding that each [param] needs delimiters; refactor mistakes when splitting a static segment into params.","solutions":["Insert a separator between the params: [id]-[lang].astro, [id]_[lang].astro, or [id]/[lang].astro (separate segments).","Use a single combined param and split it in code if you truly need both values in one segment.","Confirm brackets are balanced and no stray '][' remains."],"exampleFix":"// before — src/pages/[id][lang].astro\n\n// after — src/pages/[id]-[lang].astro","handlingStrategy":"validation","validationCode":"function segmentsAreSeparated(segment: string): boolean {\n  return !segment.includes('][');\n}\n// validate route segments before parsing","typeGuard":"function isValidSegment(segment: string): boolean {\n  return !segment.includes('][') &&\n    countOccurrences('[', segment) === countOccurrences(']', segment);\n}","tryCatchPattern":null,"preventionTips":["Separate adjacent params with static text: [id]-[lang].","Prefer distinct path segments ([id]/[lang]) over combined ones.","Add a CI check that scans src/pages for the '][' anti-pattern."],"tags":["routing","filesystem","validation","dynamic-routes"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}