{"id":"73cbd4114851efcf","repo":"pallets/flask","slug":"view-func-name-may-not-contain-a-dot-charact","errorCode":null,"errorMessage":"'view_func' name may not contain a dot '.' character.","messagePattern":"'view_func' name may not contain a dot '\\.' character\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/flask/sansio/blueprints.py","lineNumber":431,"sourceCode":"    def add_url_rule(\n        self,\n        rule: str,\n        endpoint: str | None = None,\n        view_func: ft.RouteCallable | None = None,\n        provide_automatic_options: bool | None = None,\n        **options: t.Any,\n    ) -> None:\n        \"\"\"Register a URL rule with the blueprint. See :meth:`.Flask.add_url_rule` for\n        full documentation.\n\n        The URL rule is prefixed with the blueprint's URL prefix. The endpoint name,\n        used with :func:`url_for`, is prefixed with the blueprint's name.\n        \"\"\"\n        if endpoint and \".\" in endpoint:\n            raise ValueError(\"'endpoint' may not contain a dot '.' character.\")\n\n        if view_func and hasattr(view_func, \"__name__\") and \".\" in view_func.__name__:\n            raise ValueError(\"'view_func' name may not contain a dot '.' character.\")\n\n        self.record(\n            lambda s: s.add_url_rule(\n                rule,\n                endpoint,\n                view_func,\n                provide_automatic_options=provide_automatic_options,\n                **options,\n            )\n        )\n\n    @t.overload\n    def app_template_filter(self, name: T_template_filter) -> T_template_filter: ...\n    @t.overload\n    def app_template_filter(\n        self, name: str | None = None\n    ) -> t.Callable[[T_template_filter], T_template_filter]: ...\n    @setupmethod","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/pallets/flask/blob/6a2f545bfd8ed31e19066a299296917e034aca58/src/flask/sansio/blueprints.py#L413-L449","documentation":"Flask blueprints derive endpoint names from the view function's __name__ when no explicit endpoint is given, and endpoints use dots as namespace separators (blueprint_name.endpoint). If the function name itself contains a dot, the generated endpoint would collide with the blueprint namespacing scheme, so Blueprint.add_url_rule raises this ValueError in src/flask/sansio/blueprints.py.","triggerScenarios":"Calling bp.add_url_rule(rule, view_func=fn) or @bp.route where fn.__name__ contains a '.', e.g. a lambda or wrapper whose __name__ was manually set to 'api.users', or a functools.partial/decorated callable given a dotted __name__. Also raised (sibling check) when passing endpoint='a.b' explicitly to a blueprint.","commonSituations":"Developers trying to namespace endpoints by putting dots into function names or endpoint arguments instead of using nested blueprints; class-based views wrapped with as_view('name.with.dot'); code generators building view functions with qualified names copied into __name__.","solutions":["Rename the view function or the endpoint argument to remove the dot (use underscores, e.g. 'api_users').","If you want dotted namespacing, register a nested Blueprint instead — Flask joins names with dots automatically.","When using MethodView.as_view() or dynamic wrappers, pass a dot-free name and set an explicit endpoint= if needed."],"exampleFix":"# before\nview = make_view(); view.__name__ = 'api.users'\nbp.add_url_rule('/users', view_func=view)\n# after\nview = make_view(); view.__name__ = 'api_users'\nbp.add_url_rule('/users', view_func=view)  # url_for('bp.api_users')","handlingStrategy":"validation","validationCode":"def safe_add_url_rule(bp, rule, endpoint=None, view_func=None, **opts):\n    name = endpoint or (view_func.__name__ if view_func else None)\n    if name and '.' in name:\n        raise ValueError(f\"endpoint {name!r} contains a dot; use a plain name\")\n    bp.add_url_rule(rule, endpoint, view_func, **opts)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass an explicit endpoint= when the view function is a lambda, partial, or has a qualified __name__ containing dots","Never build endpoint names by concatenating blueprint name + '.' — Flask does the namespacing for you","Check functools.partial/decorated views: ensure functools.wraps preserved a clean __name__"],"tags":["flask","blueprint","routing"],"analyzedSha":"6a2f545bfd8ed31e19066a299296917e034aca58","analyzedAt":"2026-07-31T19:13:49.921Z","schemaVersion":2}