codeant-ai-for-open-source[bot] commented on code in PR #42339:
URL: https://github.com/apache/superset/pull/42339#discussion_r3637095884
##########
superset/commands/tag/export.py:
##########
@@ -23,33 +23,56 @@
import yaml
from superset.daos.chart import ChartDAO
from superset.daos.dashboard import DashboardDAO
+from superset.daos.tag import TagDAO
from superset.extensions import feature_flag_manager
from superset.tags.models import TagType
+from superset.commands.export.models import ExportModelsCommand
from superset.commands.tag.exceptions import TagNotFoundError
-# pylint: disable=too-few-public-methods
-class ExportTagsCommand:
+class ExportTagsCommand(ExportModelsCommand):
+ dao = TagDAO
not_found = TagNotFoundError
+ def __init__(
+ self,
+ model_ids: Optional[list[int]] = None,
+ export_related: bool = True,
+ *,
+ dashboard_ids: Optional[Union[int, List[Union[int, str]]]] = None,
+ chart_ids: Optional[Union[int, List[Union[int, str]]]] = None,
+ ):
+ self.model_ids = model_ids or []
+ self.export_related = export_related
+ self.dashboard_ids = dashboard_ids
+ self.chart_ids = chart_ids
+ self._models = []
+
+ def run(self) -> Iterator[tuple[str, Callable[[], str]]]:
+ if not feature_flag_manager.is_feature_enabled("TAGGING_SYSTEM"):
+ return
+
+ yield (
+ ExportTagsCommand._file_name(),
+ lambda: ExportTagsCommand._file_content(
+ self.dashboard_ids, self.chart_ids
+ ),
+ )
Review Comment:
**Suggestion:** `ExportTagsCommand` now advertises the `ExportModelsCommand`
interface (`model_ids`, `dao`, `not_found`) but `run()` completely ignores
`model_ids` and only exports from `dashboard_ids`/`chart_ids`. Any caller using
the standard parent-style invocation (for example `ExportTagsCommand([id1,
id2]).run()`) will silently produce incorrect/empty tag exports. Make `run()`
honor `model_ids` (or delegate to parent flow) so the subclass contract is not
broken. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Tag export via model_ids returns empty tags file.
- ⚠️ Future generic export pipeline mis-exports tag resources.
- ⚠️ Silent mismatch between ExportModelsCommand contract and behavior.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Ensure the `TAGGING_SYSTEM` feature flag is enabled so
`feature_flag_manager.is_feature_enabled("TAGGING_SYSTEM")` at
`superset/commands/tag/export.py:52` returns True, allowing
`ExportTagsCommand.run()` to
proceed.
2. From any caller (e.g. a management command or test), instantiate the
command using the
standard `ExportModelsCommand` pattern: `cmd =
ExportTagsCommand(model_ids=[1, 2])`; this
executes `__init__` at `superset/commands/tag/export.py:37-49`, setting
`self.model_ids =
[1, 2]` and leaving `self.dashboard_ids` and `self.chart_ids` as `None`.
3. Call `result = list(cmd.run())`, which enters `run()` at
`superset/commands/tag/export.py:51-60`. Because `run()` ignores
`self.model_ids` and only
calls `_file_content(self.dashboard_ids, self.chart_ids)`, `_file_content` at
`superset/commands/tag/export.py:79-133` receives both arguments as `None`.
4. Observe that `_file_content` builds `payload = {"tags": []}` and, with no
`dashboard_ids` or `chart_ids`, never loads any tags; the iterator from
`run()` yields a
single `("tags.yaml", <lambda>)` where the lambda returns YAML containing an
empty `tags`
list, silently ignoring the requested tag IDs [1, 2] passed via `model_ids`.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3ac58a7b5834400eb4d54070a34a0826&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=3ac58a7b5834400eb4d54070a34a0826&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/commands/tag/export.py
**Line:** 37:60
**Comment:**
*Logic Error: `ExportTagsCommand` now advertises the
`ExportModelsCommand` interface (`model_ids`, `dao`, `not_found`) but `run()`
completely ignores `model_ids` and only exports from
`dashboard_ids`/`chart_ids`. Any caller using the standard parent-style
invocation (for example `ExportTagsCommand([id1, id2]).run()`) will silently
produce incorrect/empty tag exports. Make `run()` honor `model_ids` (or
delegate to parent flow) so the subclass contract is not broken.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42339&comment_hash=832f648e3b75ab2ed3ca82081bae433d609015690fff8444a4a2c7abe9db813f&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42339&comment_hash=832f648e3b75ab2ed3ca82081bae433d609015690fff8444a4a2c7abe9db813f&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]