reflex-dev/reflex · error · ValueError
Catchall pattern `{part}` is not valid. Only `{constants.Rou
Error message
Catchall pattern `{part}` is not valid. Only `{constants.RouteRegex.SPLAT_CATCHALL}` is allowed. What it means
Reflex only supports one catchall pattern spelling: [[...slug]] (constants.RouteRegex.SPLAT_CATCHALL). Any other bracketed segment starting with '[[...' or '[...' (e.g. '[...args]', '[[...catch]]') is rejected by verify_route_validity when the page is added.
Source
Thrown at reflex/route.py:34
route: The route that need to be checked
Raises:
ValueError: If the route is invalid.
"""
route_parts = route.removeprefix("/").split("/")
for i, part in enumerate(route_parts):
if constants.RouteRegex.SLUG.fullmatch(part):
continue
if not part.startswith("[") or not part.endswith("]"):
msg = (
f"Route part `{part}` is not valid. Reflex only supports "
"alphabetic characters, underscores, and hyphens in route parts. "
)
raise ValueError(msg)
if part.startswith(("[[...", "[...")):
if part != constants.RouteRegex.SPLAT_CATCHALL:
msg = f"Catchall pattern `{part}` is not valid. Only `{constants.RouteRegex.SPLAT_CATCHALL}` is allowed."
raise ValueError(msg)
if i != len(route_parts) - 1:
msg = f"Catchall pattern `{part}` must be at the end of the route."
raise ValueError(msg)
continue
if part.startswith("[["):
if constants.RouteRegex.OPTIONAL_ARG.fullmatch(part):
continue
msg = (
f"Route part `{part}` with optional argument is not valid. "
"Reflex only supports optional arguments that start with an alphabetic character or underscore, "
"followed by alphanumeric characters or underscores."
)
raise ValueError(msg)
if not constants.RouteRegex.ARG.fullmatch(part):
msg = (
f"Route part `{part}` with argument is not valid. "
"Reflex only supports argument names that start with an alphabetic character or underscore, "
"followed by alphanumeric characters or underscores."View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Use exactly [[...slug]] as the catchall segment, e.g. route='/docs/[[...slug]]'
- If you need a custom name, access the args via the default slug name in the page's state instead of renaming the route segment
Example fix
# before app.add_page(docs, route='/docs/[...path]') # after app.add_page(docs, route='/docs/[[...slug]]')
Defensive patterns
Strategy: validation
Validate before calling
from reflex.utils.constants import RouteRegex
def is_valid_catchall(part: str) -> bool:
return part == RouteRegex.SPLAT_CATCHALL.value if hasattr(RouteRegex.SPLAT_CATCHALL, 'value') else part == RouteRegex.SPLAT_CATCHALL.pattern Type guard
def is_valid_route_part(part: str) -> bool:
if part.startswith(('[[...', '[...')):
return part == '[[...slug]]'
return True Try / catch
try:
app.add_page(page, route=route)
except ValueError as e:
print(f'bad route: {e}') Prevention
- Memorize the single allowed catchall spelling [[...slug]]
- Add a test asserting all catchall routes equal [[...slug]]
When it happens
Trigger: app.add_page(catch, route='/docs/[...path]') or '/docs/[[...path]]'-variants that don't exactly equal '[[...slug]]', such as different arg names or single brackets.
Common situations: Coming from Next.js where any name like [...slug] or [...path] works; renaming the catchall arg to something meaningful like 'path' or 'rest'.
Related errors
- Catchall pattern `{part}` must be at the end of the route.
- Route part `{part}` is not valid. Reflex only supports alpha
- Route part `{part}` with optional argument is not valid. Ref
- Route part `{part}` with argument is not valid. Reflex only
- Arg name `{arg_name}` is used more than once in the route `{
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/3a2be83aec94cc13.
Report an issue: GitHub.