{"record":{"id":"9d8c7bc874d02585","repo":"pallets/flask","slug":"name-may-not-be-empty","errorCode":null,"errorMessage":"'name' may not be empty.","messagePattern":"'name' may not be empty\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/flask/sansio/blueprints.py","lineNumber":196,"sourceCode":"        static_folder: str | os.PathLike[str] | None = None,\n        static_url_path: str | None = None,\n        template_folder: str | os.PathLike[str] | None = None,\n        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:","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/pallets/flask/blob/3596b1ab61cea85edb8970e83ff61daa073facf8/src/flask/sansio/blueprints.py#L178-L214","documentation":"Blueprint.__init__ requires a non-empty name; the name becomes the URL/endpoint prefix and is used as a dict key, so an empty string is rejected with ValueError. The check is `if not name`, so None, '', and other falsy values all trip it.","triggerScenarios":"Constructing Blueprint('') or Blueprint(name) where name is computed as an empty string; passing name=None; deriving name from a filename/module that yielded empty.","commonSituations":"Programmatic blueprint generation from a config value that is missing/empty; refactoring that accidentally passes import_name as the first positional twice or drops the name; copy-paste leaving the name blank.","solutions":["Pass a non-empty, unique name as the first positional argument to Blueprint.","If the name comes from config, validate it is a non-empty string before constructing the Blueprint.","Use the module's __name__ convention: Blueprint(__name__.split('.')[-1]) but guard against empty results."],"exampleFix":"// before\nbp = Blueprint('')\n\n// after\nbp = Blueprint('admin')","handlingStrategy":"validation","validationCode":"def validate_bp_name(name: str) -> str:\n    if not name:\n        raise ValueError('Blueprint name required')\n    return name\n","typeGuard":"def is_valid_bp_name(name) -> bool:\n    return isinstance(name, str) and bool(name)\n","tryCatchPattern":null,"preventionTips":["Pass a literal non-empty name when constructing Blueprint.","Validate config-derived names before constructing the Blueprint.","Prefer __name__.split('.')[-1] over raw module paths."],"tags":["flask","blueprint","validation","configuration"],"backgroundTag":null,"analyzedSha":"3596b1ab61cea85edb8970e83ff61daa073facf8","analyzedAt":"2026-08-11T20:11:52.622Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}