Compare commits

...
Author SHA1 Message Date
Claude Code 1f0ccab62d fix(daos): correct broken import of current_user_can_modify_object
superset/daos/tag.py imported current_user_can_modify_object from
superset.commands.tag.utils, which has never defined or re-exported it -
the function only exists in superset.commands.utils. This broke app boot
entirely, since superset.commands.utils itself imports TagDAO, so any
request through ChartRestApi -> commands/chart/create.py ->
commands/utils.py -> daos/tag.py hit the bad import at module load time.

Importing it directly from commands.utils at module level would create a
circular import (commands.utils -> daos.tag -> commands.utils), so the
import is deferred to call time in create_tag_relationship, the one
place daos/tag.py needs it - matching the existing deferred-import
pattern used elsewhere in this codebase for the same reason.

Introduced by #43390.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-24 09:11:59 -07:00
2 changed files with 9 additions and 7 deletions
+7 -5
View File
@@ -21,11 +21,7 @@ from flask import g
from sqlalchemy.exc import NoResultFound
from superset.commands.tag.exceptions import TagNotFoundError
from superset.commands.tag.utils import (
current_user_can_modify_object,
to_object_model,
to_object_type,
)
from superset.commands.tag.utils import to_object_model, to_object_type
from superset.daos.base import BaseDAO
from superset.daos.chart import ChartDAO
from superset.daos.dashboard import DashboardDAO
@@ -349,6 +345,12 @@ class TagDAO(BaseDAO[Tag]):
Returns:
None.
"""
# Deferred: superset.commands.utils imports TagDAO, so a module-level
# import here would be circular.
from superset.commands.utils import ( # pylint: disable=import-outside-toplevel
current_user_can_modify_object,
)
tagged_objects = []
if not tag:
raise TagNotFoundError()
@@ -323,7 +323,7 @@ def test_update_command_skips_removal_of_inaccessible_objects(
side_effect=can_modify,
)
mocker.patch(
"superset.daos.tag.current_user_can_modify_object",
"superset.commands.utils.current_user_can_modify_object",
side_effect=can_modify,
)
@@ -397,7 +397,7 @@ def test_update_command_empty_objects_to_tag_only_removes_accessible(
side_effect=can_modify,
)
mocker.patch(
"superset.daos.tag.current_user_can_modify_object",
"superset.commands.utils.current_user_can_modify_object",
side_effect=can_modify,
)