{"id":"0974c9f9a357d799","repo":"pallets/flask","slug":"name-may-not-contain-a-dot-character","errorCode":null,"errorMessage":"'name' may not contain a dot '.' character.","messagePattern":"'name' may not contain a dot '\\.' character\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/flask/sansio/blueprints.py","lineNumber":199,"sourceCode":"        url_prefix: str | None = None,\n        subdomain: str | None = None,\n        url_defaults: dict[str, t.Any] | None = None,\n        root_path: str | None = None,\n        cli_group: str | None = _sentinel,  # type: ignore[assignment]\n    ):\n        super().__init__(\n            import_name=import_name,\n            static_folder=static_folder,\n            static_url_path=static_url_path,\n            template_folder=template_folder,\n            root_path=root_path,\n        )\n\n        if not name:\n            raise ValueError(\"'name' may not be empty.\")\n\n        if \".\" in name:\n            raise ValueError(\"'name' may not contain a dot '.' character.\")\n\n        self.name = name\n        self.url_prefix = url_prefix\n        self.subdomain = subdomain\n        self.deferred_functions: list[DeferredSetupFunction] = []\n\n        if url_defaults is None:\n            url_defaults = {}\n\n        self.url_values_defaults = url_defaults\n        self.cli_group = cli_group\n        self._blueprints: list[tuple[Blueprint, dict[str, t.Any]]] = []\n\n    def _check_setup_finished(self, f_name: str) -> None:\n        if self._got_registered_once:\n            raise AssertionError(\n                f\"The setup method '{f_name}' can no longer be called on the blueprint\"\n                f\" '{self.name}'. It has already been registered at least once, any\"","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/pallets/flask/blob/6a2f545bfd8ed31e19066a299296917e034aca58/src/flask/sansio/blueprints.py#L181-L217","documentation":"A ValueError from `Blueprint.__init__` (src/flask/sansio/blueprints.py:198-199). Flask uses the dot as the namespace separator for nested blueprints and endpoints (`parent.child.view` in `url_for`), so a dot inside a single blueprint's name would make it indistinguishable from a nesting hierarchy and corrupt endpoint resolution. This became a hard error in Flask 2.0 when nested blueprints were introduced; before that it was a deprecation warning.","triggerScenarios":"`Blueprint('api.v1', __name__)` or any name containing '.', including names auto-derived from module paths like `Blueprint(__name__, __name__)` where `__name__` is 'myapp.views'.","commonSituations":"Trying to express versioned namespaces ('api.v1') in the name instead of using nested blueprints or url_prefix; passing `__name__` (a dotted module path) as the blueprint name; upgrading from Flask 1.x where dotted names only warned.","solutions":["Replace the dot with another separator: `Blueprint('api_v1', __name__)`, and express the URL structure via `url_prefix='/api/v1'`.","If you want real hierarchy, create separate blueprints and nest them with `parent.register_blueprint(child)` — Flask joins the names with dots for you.","If deriving the name from a module path, take the last segment: `__name__.rsplit('.', 1)[-1]`."],"exampleFix":"# before\nbp = Blueprint(\"api.v1\", __name__)\n\n# after\nbp = Blueprint(\"api_v1\", __name__, url_prefix=\"/api/v1\")","handlingStrategy":"validation","validationCode":"if '.' in name:\n    name = name.replace('.', '_')\nbp = Blueprint(name, __name__)","typeGuard":"def is_valid_bp_name(name):\n    return isinstance(name, str) and name and '.' not in name","tryCatchPattern":null,"preventionTips":["Dots are reserved for blueprint nesting separators — use underscores or hyphens in names","Don't derive blueprint names from module paths (e.g. __name__ contains dots); use the last segment: __name__.rsplit('.', 1)[-1]","For hierarchy, register nested blueprints instead of encoding hierarchy in the name"],"tags":["flask","python","blueprints","naming","validation"],"analyzedSha":"6a2f545bfd8ed31e19066a299296917e034aca58","analyzedAt":"2026-07-31T19:13:49.921Z","schemaVersion":2}