{"record":{"id":"212b5cabbc8b9036","repo":"vercel/next.js","slug":"you-cannot-define-a-route-with-the-same-specificit","errorCode":null,"errorMessage":"You cannot define a route with the same specificity as a optional catch-all route (\"${r}\" and \"${r}[[...${this.optionalRestSlugName}]]\").","messagePattern":"You cannot define a route with the same specificity as a optional catch-all route \\(\"(.+?)\" and \"(.+?)\\[\\[\\.\\.\\.(.+?)\\]\\]\"\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/shared/lib/router/utils/sorted-routes.ts","lineNumber":41,"sourceCode":"    }\n    if (this.optionalRestSlugName !== null) {\n      childrenPaths.splice(childrenPaths.indexOf('[[...]]'), 1)\n    }\n\n    const routes = childrenPaths\n      .map((c) => this.children.get(c)!._smoosh(`${prefix}${c}/`))\n      .reduce((prev, curr) => [...prev, ...curr], [])\n\n    if (this.slugName !== null) {\n      routes.push(\n        ...this.children.get('[]')!._smoosh(`${prefix}[${this.slugName}]/`)\n      )\n    }\n\n    if (!this.placeholder) {\n      const r = prefix === '/' ? '/' : prefix.slice(0, -1)\n      if (this.optionalRestSlugName != null) {\n        throw new Error(\n          `You cannot define a route with the same specificity as a optional catch-all route (\"${r}\" and \"${r}[[...${this.optionalRestSlugName}]]\").`\n        )\n      }\n\n      routes.unshift(r)\n    }\n\n    if (this.restSlugName !== null) {\n      routes.push(\n        ...this.children\n          .get('[...]')!\n          ._smoosh(`${prefix}[...${this.restSlugName}]/`)\n      )\n    }\n\n    if (this.optionalRestSlugName !== null) {\n      routes.push(\n        ...this.children","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/shared/lib/router/utils/sorted-routes.ts#L23-L59","documentation":"During route-tree sorting (_smoosh in SortedRoutes), a directory level that contains an optional catch-all [[...slug]] cannot also define a plain route at that same level: the optional catch-all already matches the exact path, producing ambiguous duplicate specificity. Fires while validating pages-router file routes at build/dev time.","triggerScenarios":"A route conflicts with an optional catch-all route at the same specificity.","commonSituations":"Defining both a static route and an [[...slug]] route that would match the same paths.","solutions":["Remove the duplicate route that conflicts with the optional catch-all route."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}