{"record":{"id":"b1a67b321041ca92","repo":"sveltejs/kit","slug":"the-lookup-get-key-and-route-id-routes","errorCode":null,"errorMessage":"The \"${lookup.get(key)}\" and \"${route.id}\" routes conflict with each other","messagePattern":"The \"(.+?)\" and \"(.+?)\" routes conflict with each other","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/sync/create_manifest_data/conflict.js","lineNumber":45,"sourceCode":"\t\t\t\t\ta.push(b + next);\n\t\t\t\t\tif (!(matcher === '*' && b.endsWith('//'))) a.push(b + `<${matcher}>${next}`);\n\t\t\t\t\treturn a;\n\t\t\t\t}, /** @type {string[]} */ ([]));\n\t\t\t}\n\t\t} else {\n\t\t\tpermutations = [normalized];\n\t\t}\n\n\t\tfor (const permutation of permutations) {\n\t\t\t// remove leading/trailing/duplicated slashes caused by prior\n\t\t\t// manipulation of optional parameters and (groups)\n\t\t\tconst key = permutation\n\t\t\t\t.replace(/\\/{2,}/, '/')\n\t\t\t\t.replace(/^\\//, '')\n\t\t\t\t.replace(/\\/$/, '');\n\n\t\t\tif (lookup.has(key)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The \"${lookup.get(key)}\" and \"${route.id}\" routes conflict with each other`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlookup.set(key, route.id);\n\t\t}\n\t}\n}\n\n/** @param {string} id */\nfunction normalize_route_id(id) {\n\treturn (\n\t\tid\n\t\t\t// remove groups\n\t\t\t.replace(/(?<=^|\\/)\\(.+?\\)(?=$|\\/)/g, '')\n\n\t\t\t.replace(/\\[[ux]\\+([0-9a-f]+)\\]/g, (_, x) =>\n\t\t\t\tString.fromCodePoint(parseInt(x, 16)).replace(/\\//g, '%2f')","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/sync/create_manifest_data/conflict.js#L27-L63","documentation":"Two routes in src/routes normalize to the same URL pattern (same permutation of segments after removing duplicate slashes and trailing slashes). SvelteKit cannot decide which route handles that URL, so manifest creation fails at dev start or build.","triggerScenarios":"Creating e.g. `src/routes/about/[page]` and `src/routes/[category]/about` that produce identical path permutations; duplicate optional-param routes like `/[[x]]` and a static `/` route both matching the same key.","commonSituations":"Refactoring route names and leaving an old duplicate; route groups (`(group)`) accidentally flattening two routes to the same path; optional parameters colliding with static siblings.","solutions":["Read both conflicting route ids from the error and delete or rename one","Differentiate the patterns, e.g. add a literal prefix segment to one route","Replace optional parameters with explicit routes or a single catch-all `[...slug]` with logic","Check route groups — moving files between (groups) changes nothing about matching, so the duplicate remains"],"exampleFix":"// before — both match /x/about\n// src/routes/[category]/about/+page.svelte\n// src/routes/about/[page]/+page.svelte\n\n// after\n// src/routes/category/[name]/about/+page.svelte  (add literal 'category' segment)","handlingStrategy":"validation","validationCode":"// before starting dev/build, list route dirs and flag normalized duplicates\nimport { readdirSync } from 'node:fs';\nconst segs = readdirSync('src/routes', { recursive: true }).filter((p) => p.endsWith('+page.svelte'));\nconst seen = new Map();\nfor (const s of segs) {\n  const key = s.replace(/\\/+page\\.svelte/, '').replace(/\\/+$/, '');\n  if (seen.has(key)) console.warn('Conflict:', seen.get(key), 'vs', s);\n  seen.set(key, s);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const manifest = await createManifestData(config);\n} catch (e) {\n  if (String(e.message).includes('routes conflict with each other')) {\n    console.error('Rename one of the two conflicting routes listed in the message');\n  }\n  throw e;\n}","preventionTips":["Avoid optional params [[x]] adjacent to static siblings that match the same URL","Remember (group) folders do not change URL matching — check for duplicates they create","Sketch your route table after refactors to verify uniqueness"],"tags":["routing","routes","conflict","dev-time"],"backgroundTag":"route-pattern-conflict","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}