{"record":{"id":"aa5e19ef09f92cf7","repo":"reflex-dev/reflex","slug":"catchall-pattern-part-must-be-at-the-end-of-th","errorCode":null,"errorMessage":"Catchall pattern `{part}` must be at the end of the route.","messagePattern":"Catchall pattern `(.+?)` must be at the end of the route\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"reflex/route.py","lineNumber":37,"sourceCode":"        ValueError: If the route is invalid.\n    \"\"\"\n    route_parts = route.removeprefix(\"/\").split(\"/\")\n    for i, part in enumerate(route_parts):\n        if constants.RouteRegex.SLUG.fullmatch(part):\n            continue\n        if not part.startswith(\"[\") or not part.endswith(\"]\"):\n            msg = (\n                f\"Route part `{part}` is not valid. Reflex only supports \"\n                \"alphabetic characters, underscores, and hyphens in route parts. \"\n            )\n            raise ValueError(msg)\n        if part.startswith((\"[[...\", \"[...\")):\n            if part != constants.RouteRegex.SPLAT_CATCHALL:\n                msg = f\"Catchall pattern `{part}` is not valid. Only `{constants.RouteRegex.SPLAT_CATCHALL}` is allowed.\"\n                raise ValueError(msg)\n            if i != len(route_parts) - 1:\n                msg = f\"Catchall pattern `{part}` must be at the end of the route.\"\n                raise ValueError(msg)\n            continue\n        if part.startswith(\"[[\"):\n            if constants.RouteRegex.OPTIONAL_ARG.fullmatch(part):\n                continue\n            msg = (\n                f\"Route part `{part}` with optional argument is not valid. \"\n                \"Reflex only supports optional arguments that start with an alphabetic character or underscore, \"\n                \"followed by alphanumeric characters or underscores.\"\n            )\n            raise ValueError(msg)\n        if not constants.RouteRegex.ARG.fullmatch(part):\n            msg = (\n                f\"Route part `{part}` with argument is not valid. \"\n                \"Reflex only supports argument names that start with an alphabetic character or underscore, \"\n                \"followed by alphanumeric characters or underscores.\"\n            )\n            raise ValueError(msg)\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/route.py#L19-L55","documentation":"A catchall route segment ([[...slug]]) matches arbitrary trailing path segments, so Reflex requires it to be the final part of the route. verify_route_validity raises this ValueError when the catchall appears anywhere except the last position.","triggerScenarios":"Routes like '/blog/[[...slug]]/edit' or '/api/[[...slug]]/detail' where segments follow the catchall.","commonSituations":"Designing nested dynamic routes and assuming catchall works like a prefix wildcard; porting Express '*' middleware style routes.","solutions":["Move the catchall to the end: '/blog/edit/[[...slug]]'","Or split into separate routes for the fixed suffixes and a catchall-only route","Handle suffix logic inside the page by parsing the slug list from route args"],"exampleFix":"# before\napp.add_page(page, route='/blog/[[...slug]]/edit')\n\n# after\napp.add_page(page, route='/blog/[[...slug]]')","handlingStrategy":"validation","validationCode":"def validate_route(route: str):\n    parts = [p for p in route.strip('/').split('/') if p]\n    for i, p in enumerate(parts[:-1]):\n        if p.startswith(('[[...', '[...')):\n            raise ValueError('catchall must be last')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the catchall as a terminal wildcard only","Design fixed prefixes before the catchall, never after"],"tags":["reflex","routing","catchall","validation"],"backgroundTag":"route-pattern-validation-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}