{"record":{"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":"exception","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/3596b1ab61cea85edb8970e83ff61daa073facf8/src/flask/sansio/blueprints.py#L181-L217","documentation":"Blueprint name cannot contain '.' because Flask uses dot as a separator between blueprint name and endpoint (e.g. 'bp.view') and between name_prefix and name. A dot in the name would corrupt endpoint resolution and url_for. The constructor raises ValueError on `if '.' in name`.","triggerScenarios":"Passing Blueprint('my.blueprint'); deriving the name from a dotted module path without splitting; concatenating names with dots.","commonSituations":"Using __name__ (dotted import path) directly as the blueprint name instead of the leaf; building names from f-strings with dots; migrating code that previously allowed dots.","solutions":["Use the leaf module name: __name__.split('.')[-1] or just a plain identifier like 'admin'.","Strip or replace dots before constructing: name.replace('.', '_').","If you need hierarchical names, use the name_prefix option at registration time instead of dots in the name."],"exampleFix":"// before\nbp = Blueprint(__name__)  # __name__ == 'myapp.admin.blueprint'\n\n// after\nbp = Blueprint(__name__.split('.')[-1])  # 'blueprint'","handlingStrategy":"validation","validationCode":"def validate_bp_name(name: str) -> str:\n    if '.' in name:\n        raise ValueError('Blueprint name must not contain a dot')\n    return name\n","typeGuard":"def is_bp_name_dot_free(name) -> bool:\n    return isinstance(name, str) and '.' not in name\n","tryCatchPattern":null,"preventionTips":["Never pass a dotted module path as the blueprint name; use the leaf.","Use name_prefix at registration for hierarchy, not dots in the name.","Lint for Blueprint(__name__)."],"tags":["flask","blueprint","validation","naming"],"backgroundTag":null,"analyzedSha":"3596b1ab61cea85edb8970e83ff61daa073facf8","analyzedAt":"2026-08-11T20:11:52.622Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}