aio-libs/aiohttp · error · ValueError

Incorrect route name {name!r}, the name should be a sequence

Error message

Incorrect route name {name!r}, the name should be a sequence of python identifiers separated by dash, dot or column

What it means

Error "Incorrect route name {name!r}, the name should be a sequence of python identifiers separated by dash, dot or column" thrown in aio-libs/aiohttp.

Source

Thrown at aiohttp/web_urldispatcher.py:1059

        assert isinstance(
            resource, AbstractResource
        ), f"Instance of AbstractResource class is required, got {resource!r}"
        if self.frozen:
            raise RuntimeError("Cannot register a resource into frozen router.")

        name = resource.name

        if name is not None:
            parts = self.NAME_SPLIT_RE.split(name)
            for part in parts:
                if keyword.iskeyword(part):
                    raise ValueError(
                        f"Incorrect route name {name!r}, "
                        "python keywords cannot be used "
                        "for route name"
                    )
                if not part.isidentifier():
                    raise ValueError(
                        f"Incorrect route name {name!r}, "
                        "the name should be a sequence of "
                        "python identifiers separated "
                        "by dash, dot or column"
                    )
            if name in self._named_resources:
                raise ValueError(
                    f"Duplicate {name!r}, "
                    f"already handled by {self._named_resources[name]!r}"
                )
            self._named_resources[name] = resource
        self._resources.append(resource)

        if isinstance(resource, MatchedSubAppResource):
            # We cannot index match sub-app resources because they have match rules
            self._matched_sub_app_resources.append(resource)
        else:
            self.index_resource(resource)

View on GitHub (pinned to c0ef574e29)

When it happens

Trigger: Thrown at aiohttp/web_urldispatcher.py:1059 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of aio-libs/aiohttp@c0ef574e29 (2026-08-04). Data as JSON: /data/errors/e1ba41448081eb33.json. Report an issue: GitHub.