{"id":"c95ee4186522c8ee","repo":"pallets/flask","slug":"endpoint-may-not-contain-a-dot-character","errorCode":null,"errorMessage":"'endpoint' may not contain a dot '.' character.","messagePattern":"'endpoint' may not contain a dot '\\.' character\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/flask/sansio/blueprints.py","lineNumber":428,"sourceCode":"        extend(self.template_context_processors, app.template_context_processors)\n\n    @setupmethod\n    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(","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/pallets/flask/blob/6a2f545bfd8ed31e19066a299296917e034aca58/src/flask/sansio/blueprints.py#L410-L446","documentation":"A ValueError from `Blueprint.add_url_rule` (src/flask/sansio/blueprints.py:427-428). Blueprint endpoints are automatically prefixed with the blueprint's (possibly nested, dot-joined) name to form `blueprint.endpoint`; a dot inside the local endpoint segment would fake an extra nesting level and break `url_for` resolution, so it's rejected. The companion check on line 430-431 applies the same rule to `view_func.__name__` since that supplies the default endpoint.","triggerScenarios":"`@bp.route('/x', endpoint='api.get_x')` or `bp.add_url_rule('/x', 'users.list', f)` — any explicit endpoint containing '.' on a blueprint. Also hit indirectly when a view function's `__name__` contains a dot (e.g. assigned dynamically), which raises the sibling 'view_func' variant.","commonSituations":"Habits carried over from app-level `url_for('bp.view')` strings — developers write the fully qualified name as the endpoint; migrating pre-2.0 code where dotted endpoints on blueprints only warned; generating endpoints from dotted module paths in plugin loaders.","solutions":["Use only the local segment as the endpoint (`endpoint='get_x'`); Flask prepends the blueprint name automatically, and `url_for('api.get_x')` still works.","For real hierarchy, nest blueprints (`parent.register_blueprint(child)`) instead of encoding dots in endpoint names.","If endpoints are generated from module paths, sanitize them: `path.replace('.', '_')` or take the last segment."],"exampleFix":"# before\n@bp.route(\"/items\", endpoint=\"api.list_items\")\ndef list_items(): ...\n\n# after\n@bp.route(\"/items\", endpoint=\"list_items\")\ndef list_items(): ...\n# url_for(\"api.list_items\") — prefix added by the blueprint","handlingStrategy":"validation","validationCode":"if '.' in endpoint:\n    raise ValueError('blueprint endpoint must not contain dots')\nbp.add_url_rule('/x', endpoint=endpoint, view_func=view)","typeGuard":"def is_valid_bp_endpoint(endpoint):\n    return isinstance(endpoint, str) and '.' not in endpoint","tryCatchPattern":null,"preventionTips":["On a blueprint, pass only the bare endpoint name — Flask prefixes 'bpname.' automatically","Never write endpoint='bp.view'; use endpoint='view' and reference it in url_for as 'bp.view'","Watch for undecorated wrapped functions whose __qualname__/__name__ contains dots when auto-deriving endpoints"],"tags":["flask","python","blueprints","endpoint","routing","validation"],"analyzedSha":"6a2f545bfd8ed31e19066a299296917e034aca58","analyzedAt":"2026-07-31T19:13:49.921Z","schemaVersion":2}