rusackas opened a new pull request, #43471:
URL: https://github.com/apache/superset/pull/43471
### SUMMARY
On #43390, villebro noted that these system-generated tags appear to be
unused, and suggested considering removing them entirely.
Confirmed: every tags list and filter in the frontend explicitly excludes
non-custom tags — `ChartList`, `DashboardList`, `SavedQueryList`, the chart
`PropertiesModal`, the dashboard `Header`, and `features/tags/tags.ts`'s
`fetchAllTags`/`fetchTags` all filter to `TagType.custom` only. Nothing in the
UI ever surfaced a `type:`/`editor:`/`favorited_by:` tag or let a user
search/filter by one — the docstring's own promise ("user alice can find all
their objects by querying for the tag `editor:alice`") had no UI path to
actually do that.
What remained was pure write-side overhead: with `TAGGING_SYSTEM` enabled,
13 SQLAlchemy event listeners across 5 models
(chart/dashboard/query/dataset/favorite) fired on every insert/update/delete,
writing `Tag`/`TaggedObject` rows nobody ever read. There was even a whole
performance-optimization mixin (`CustomTagsOptimizationMixin`,
`DASHBOARD_LIST_CUSTOM_TAGS_ONLY`) that existed purely to strip this noise back
out of dashboard-list API responses — evidence this was a known cost nobody had
gotten around to addressing at the source.
**What this removes:**
- `superset/tags/models.py`: `ObjectUpdater`'s `editor:`/`type:` generation
(`after_insert`/`after_update`) and `FavStarUpdater`'s `favorited_by:`
generation, entirely.
- `superset/tags/core.py`: only registers the delete-cleanup listeners now
(see below).
- `superset/common/tags.py` and the `sync_tags` CLI command: the backfill
path for the generation this removes.
- `superset/views/custom_tags_api_mixin.py`,
`DASHBOARD_LIST_CUSTOM_TAGS_ONLY`, `Dashboard.custom_tags`, and the schema/API
plumbing built around them: nothing left to optimize away once implicit tags
stop accumulating.
**What's kept, on purpose:**
- `ObjectUpdater.after_delete` — cleans up `tagged_object` rows for *every*
tag on a deleted object, custom tags included. `tagged_object.object_id`
carries no foreign key (see its column comment), so this is the only thing that
prevents orphaned rows when a chart/dashboard/query/dataset is hard-deleted —
not part of the removed generation, added a regression test for it
(`test_tagged_object_cleanup_on_dashboard_delete`).
- The `TagType` enum values, the `custom_tag` API filter, and bulk-delete
protection for non-custom tags — for backward compatibility with upgraded
deployments that already have `type:`/`editor:`/`favorited_by:` rows, and
because MCP's `list_tags`/`get_tag_info` tools document and support filtering
by these tag types. Docstrings updated to say these are legacy/no longer
generated rather than actively implicit.
**Unrelated but blocking:** this branch also carries
[#43467](https://github.com/apache/superset/pull/43467) as its first commit — a
genuinely broken import in `superset/daos/tag.py` from the just-merged #43390
(`current_user_can_modify_object` doesn't live in
`superset.commands.tag.utils`) that otherwise breaks Flask app boot entirely
and blocks every test in this area. Filed separately since it's unrelated; this
branch will drop that commit on its own once #43467 merges and this rebases.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — internal cleanup, no UI changes (the UI never showed these tags to
begin with).
### TESTING INSTRUCTIONS
- `pytest tests/unit_tests/tags/ tests/unit_tests/commands/test_utils.py
tests/unit_tests/initialization_test.py
tests/unit_tests/dashboards/api_test.py` — updated/removed tests for the
removed generation and mixin.
- `pytest
tests/integration_tests/tags/dao_tests.py::TestTagsDAO::test_tagged_object_cleanup_on_dashboard_delete`
— new regression test for the preserved delete-cleanup behavior.
- Full `pytest tests/unit_tests/` run: 13172 passed (the only failures are
pre-existing, unrelated to this change — a missing optional `pymysql`
dependency and a `freezegun` version quirk in files this PR doesn't touch).
- Manual: with `TAGGING_SYSTEM` enabled, create/edit/delete a chart,
dashboard, saved query, and dataset, and favorite/unfavorite one — confirm no
`type:`/`editor:`/`favorited_by:` tags appear in the `tag` table anymore, while
manually adding a custom tag and then deleting the tagged object still cleans
up its `tagged_object` row.
### ADDITIONAL INFORMATION
- [x] Has associated issue: follow-up to #43390
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [x] Removes existing feature or API
--
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]