{"record":{"id":"68fe1de90c679f69","repo":"reflex-dev/reflex","slug":"arg-name-arg-name-is-used-more-than-once-in-th","errorCode":null,"errorMessage":"Arg name `{arg_name}` is used more than once in the route `{route}`.","messagePattern":"Arg name `(.+?)` is used more than once in the route `(.+?)`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"reflex/route.py","lineNumber":73,"sourceCode":"\n\ndef get_route_args(route: str) -> dict[str, str]:\n    \"\"\"Get the dynamic arguments for the given route.\n\n    Args:\n        route: The route to get the arguments for.\n\n    Returns:\n        The route arguments.\n    \"\"\"\n    args = {}\n\n    def _add_route_arg(arg_name: str, type_: str):\n        if arg_name in args:\n            msg = (\n                f\"Arg name `{arg_name}` is used more than once in the route `{route}`.\"\n            )\n            raise ValueError(msg)\n        args[arg_name] = type_\n\n    # Regex to check for route args.\n    argument_regex = constants.RouteRegex.ARG\n    optional_argument_regex = constants.RouteRegex.OPTIONAL_ARG\n\n    # Iterate over the route parts and check for route args.\n    for part in route.split(\"/\"):\n        if part == constants.RouteRegex.SPLAT_CATCHALL:\n            _add_route_arg(\"splat\", constants.RouteArgType.LIST)\n            break\n\n        optional_argument = optional_argument_regex.match(part)\n        if optional_argument:\n            _add_route_arg(optional_argument.group(1), constants.RouteArgType.SINGLE)\n            continue\n\n        argument = argument_regex.match(part)","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/route.py#L55-L91","documentation":"Route args become keyword arguments passed to the page's state, so each dynamic segment name must be unique. get_route_args raises ValueError when the same arg name (e.g. [id] twice) appears in one route, including mixed required/optional uses like '/[id]/[[id]]'.","triggerScenarios":"app.add_page(page, route='/[id]/items/[id]') or '/user/[name]/[[name]]' — duplicate bracketed names within a single route.","commonSituations":"Building nested detail routes and reusing 'id' at multiple levels; copy-pasting route prefixes that end in the same param name.","solutions":["Rename one of the duplicates to be specific, e.g. '/[user_id]/items/[item_id]'","For parent/child relationships use prefixed names (user_id, item_id)"],"exampleFix":"# before\napp.add_page(page, route='/[id]/items/[id]')\n\n# after\napp.add_page(page, route='/[user_id]/items/[item_id]')","handlingStrategy":"validation","validationCode":"import re\n\ndef unique_route_args(route: str) -> bool:\n    names = re.findall(r'\\[+([A-Za-z_][A-Za-z0-9_]*)\\]+', route)\n    return len(names) == len(set(names))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefix nested arg names by resource (user_id, item_id)","Add a startup/test check for duplicate arg names across your routes"],"tags":["reflex","routing","duplicate-args","validation"],"backgroundTag":"route-pattern-validation-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}