shaare.it

AssertionError: Blueprint name is required

7 Dec 2025

1 min read

AssertionError: Blueprint name required

$ python -c "from flask import Blueprint; Blueprint('', __name__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AssertionError: A blueprint name is required

Why this happens

Blueprints use their name to derive endpoint prefixes and registration keys. An empty or missing name can collide with others or break routing, so Flask asserts that a valid, non-empty string is provided.

Fix

Provide a meaningful name when creating a blueprint. Keep names unique across the app.

Wrong code

from flask import Blueprint
bp = Blueprint('', __name__)

Fixed code

from flask import Blueprint
bp = Blueprint('users', __name__)

Tip

Names are used in endpoint naming (e.g., users.list). Choose short, stable names.