pallets/flask · error · ValueError
'endpoint' may not contain a dot '.' character.
Error message
'endpoint' may not contain a dot '.' character.
What it means
Blueprint.add_url_rule rejects an endpoint containing '.' because the dot is reserved as the separator between blueprint name and endpoint (final endpoint becomes 'bp.endpoint'). A dot in the user-supplied endpoint would break url_for and theBlueprint prefixing logic. Raises ValueError.
Solutions
- Remove dots from the endpoint argument: endpoint='list' instead of 'users.list'.
- Let Flask default the endpoint from the view function's __name__ (ensure that name has no dot, see error 49).
- Replace separators: endpoint.replace('.', '_').
Example fix
// before
@bp.route('/list', endpoint='users.list')
def list_users(): ...
// after
@bp.route('/list', endpoint='list')
def list_users(): ... Defensive patterns
Strategy: validation
Validate before calling
def validate_endpoint(endpoint: str | None) -> str | None:
if endpoint and '.' in endpoint:
raise ValueError("endpoint must not contain '.'")
return endpoint
Type guard
def endpoint_is_dot_free(endpoint) -> bool:
return endpoint is None or '.' not in endpoint
Prevention
- Use plain identifier endpoints inside blueprints.
- Let Flask default the endpoint from the function name when possible.
- Lint for endpoint='...'"."...'.
When it happens
Trigger: Passing endpoint='users.list' to @bp.route(...); deriving endpoint from a dotted qualified name; copy-pasting an app-level dotted endpoint into a blueprint route.
Common situations: Migrating app routes into a blueprint without renaming endpoints; using fully-qualified function names as endpoints; blueprint factories templating endpoints with dots.
Related errors
- 'name' may not contain a dot '.' character.
- 'view_func' name may not contain a dot '.' character.
- Cannot register a blueprint on itself
- 'name' may not be empty.
- The name ' ' is already registered for blueprint . Use…
AI-assisted analysis of pallets/flask@3596b1ab61 (2026-08-11).
Data as JSON: /api/errors/c95ee4186522c8ee.
Report an issue: GitHub.
Appendix: source
Thrown at src/flask/sansio/blueprints.py:428
extend(self.template_context_processors, app.template_context_processors)
@setupmethod
def add_url_rule(
self,
rule: str,
endpoint: str | None = None,
view_func: ft.RouteCallable | None = None,
provide_automatic_options: bool | None = None,
**options: t.Any,
) -> None:
"""Register a URL rule with the blueprint. See :meth:`.Flask.add_url_rule` for
full documentation.
The URL rule is prefixed with the blueprint's URL prefix. The endpoint name,
used with :func:`url_for`, is prefixed with the blueprint's name.
"""
if endpoint and "." in endpoint:
raise ValueError("'endpoint' may not contain a dot '.' character.")
if view_func and hasattr(view_func, "__name__") and "." in view_func.__name__:
raise ValueError("'view_func' name may not contain a dot '.' character.")
self.record(
lambda s: s.add_url_rule(
rule,
endpoint,
view_func,
provide_automatic_options=provide_automatic_options,
**options,
)
)
@t.overload
def app_template_filter(self, name: T_template_filter) -> T_template_filter: ...
@t.overload
def app_template_filter(View on GitHub (pinned to 3596b1ab61)