Merge branch 'fix/v2.12.1-category-unused-tags' for v2.12.1 release
Build Container / build (push) Successful in 8m3s

This commit is contained in:
Phil committed 2026-11-10 11:28:42 -07:00
commit afef1fc9a5
7 files changed
+60 -7

No files matched your search

+6
View File
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [2.12.1] - 2026-11-10
### Fixed
- Micropub `q=category` (the tag list apps use for autocomplete) only lists tags on posts that still exist. It used to include tags that an edit had removed from every post, and tags only used on deleted posts. Drafts still count; a deleted post's tags come back if it is undeleted
## [2.12.0] - 2026-11-03 ## [2.12.0] - 2026-11-03
The metrics dashboard is gone (ADR-072). The metrics dashboard is gone (ADR-072).
+5 -1
View File
@@ -21,7 +21,7 @@ is in `../architecture/`; decisions are in `../decisions/` (ADRs).
## Contents ## Contents
[v1.0.0](#v100) · [v1.1.1](#v111) · [v1.1.2](#v112) · [v1.2.0](#v120) · [v1.3.0](#v130) · [v1.3.1](#v131) · [v1.4.0](#v140) · [v1.4.1](#v141) · [v1.4.2](#v142) · [v1.5.0](#v150) · [v1.6.0](#v160) · [v2.0.0](#v200) · [v2.0.1](#v201) · [v2.0.2](#v202) · [v2.1.0](#v210) · [v2.2.0](#v220) · [v2.3.0](#v230) · [v2.3.1](#v231) · [v2.3.2](#v232) · [v2.3.3](#v233) · [v2.4.0](#v240) · [v2.5.0](#v250) · [v2.6.0](#v260) · [v2.6.1](#v261) · [v2.6.2](#v262) · [v2.6.3](#v263) · [v2.6.4](#v264) · [v2.6.5](#v265) · [v2.6.6](#v266) · [v2.6.7](#v267) · [v2.6.8](#v268) · [v2.6.9](#v269) · [v2.7.0](#v270) · [v2.7.1](#v271) · [v2.7.2](#v272) · [v2.8.0](#v280) · [v2.8.1](#v281) · [v2.9.0](#v290) · [v2.10.0](#v2100) · [v2.10.1](#v2101) · [v2.10.2](#v2102) · [v2.11.0](#v2110) · [v2.12.0](#v2120) · [hotfix](#hotfix) [v1.0.0](#v100) · [v1.1.1](#v111) · [v1.1.2](#v112) · [v1.2.0](#v120) · [v1.3.0](#v130) · [v1.3.1](#v131) · [v1.4.0](#v140) · [v1.4.1](#v141) · [v1.4.2](#v142) · [v1.5.0](#v150) · [v1.6.0](#v160) · [v2.0.0](#v200) · [v2.0.1](#v201) · [v2.0.2](#v202) · [v2.1.0](#v210) · [v2.2.0](#v220) · [v2.3.0](#v230) · [v2.3.1](#v231) · [v2.3.2](#v232) · [v2.3.3](#v233) · [v2.4.0](#v240) · [v2.5.0](#v250) · [v2.6.0](#v260) · [v2.6.1](#v261) · [v2.6.2](#v262) · [v2.6.3](#v263) · [v2.6.4](#v264) · [v2.6.5](#v265) · [v2.6.6](#v266) · [v2.6.7](#v267) · [v2.6.8](#v268) · [v2.6.9](#v269) · [v2.7.0](#v270) · [v2.7.1](#v271) · [v2.7.2](#v272) · [v2.8.0](#v280) · [v2.8.1](#v281) · [v2.9.0](#v290) · [v2.10.0](#v2100) · [v2.10.1](#v2101) · [v2.10.2](#v2102) · [v2.11.0](#v2110) · [v2.12.0](#v2120) · [v2.12.1](#v2121) · [hotfix](#hotfix)
## v1.0.0 ## v1.0.0
@@ -418,6 +418,10 @@ OIDC admin login and built-in IndieAuth server.
- [2026-11-03-remove-metrics.md](v2.12.0/2026-11-03-remove-metrics.md) - Metrics dashboard and `starpunk/monitoring` removed (ADR-072) - [2026-11-03-remove-metrics.md](v2.12.0/2026-11-03-remove-metrics.md) - Metrics dashboard and `starpunk/monitoring` removed (ADR-072)
## v2.12.1
- [2026-11-10-category-unused-tags.md](v2.12.1/2026-11-10-category-unused-tags.md) - q=category lists only tags on posts that exist
## hotfix ## hotfix
Not a release folder. Not a release folder.
@@ -0,0 +1,28 @@
# v2.12.1: q=category lists only tags in use
## Problem
`q=category` (added in v2.4.0) is what Micropub clients use for tag
autocomplete. It read every row of `tags` with a `LEFT JOIN` on
`note_tags`, so it also returned:
- tags no post uses any more (a `tags` row stays after an edit removes
the tag from its last post), and
- tags only used on soft-deleted posts (`note_tags` rows stay so that
undelete can restore them).
Clients then offered tags that appear nowhere on the site.
## Fix
`_all_categories()` in `starpunk/micropub.py` inner-joins `note_tags` and
`notes` with `deleted_at IS NULL`. Order is unchanged: most used first,
then by name. Drafts count, since they are the owner's posts. Unused
`tags` rows are left in place; nothing else reads them as a list.
## Verification
`tests/test_micropub_v240.py::TestQueries::test_category_skips_unused_tags`
retags one post and deletes another, checks only the live tag is listed,
then undeletes and checks the deleted post's tag returns. It fails on
v2.12.0.
+1 -1
View File
@@ -4,7 +4,7 @@
**Last Updated**: 2026-11-03 (v2.10.1) **Last Updated**: 2026-11-03 (v2.10.1)
StarPunk uses [Semantic Versioning 2.0.0](https://semver.org/): StarPunk uses [Semantic Versioning 2.0.0](https://semver.org/):
`MAJOR.MINOR.PATCH`, currently **2.10.1**. Every release is a git tag `MAJOR.MINOR.PATCH`, currently **2.12.1**. Every release is a git tag
`vX.Y.Z` and a `CHANGELOG.md` entry. Where the number is stored and how to `vX.Y.Z` and a `CHANGELOG.md` entry. Where the number is stored and how to
write the changelog entry is in write the changelog entry is in
[version-implementation-guide.md](version-implementation-guide.md); the [version-implementation-guide.md](version-implementation-guide.md); the
+2 -2
View File
@@ -457,5 +457,5 @@ def create_app(config=None):
# Package version (Semantic Versioning 2.0.0) # Package version (Semantic Versioning 2.0.0)
# See docs/standards/versioning-strategy.md for details # See docs/standards/versioning-strategy.md for details
__version__ = "2.12.0" __version__ = "2.12.1"
__version_info__ = (2, 12, 0) __version_info__ = (2, 12, 1)
+6 -3
View File
@@ -842,13 +842,16 @@ def note_to_mf2(note, wanted: Optional[list] = None) -> dict:
def _all_categories(prefix: str = "") -> list: def _all_categories(prefix: str = "") -> list:
"""Tags in use, most used first (q=category)""" """Tags on posts that exist (drafts included), most used first (q=category)"""
from starpunk.database import get_db from starpunk.database import get_db
# Inner joins: tags left behind by edits or soft-deleted posts don't count
rows = get_db(current_app).execute( rows = get_db(current_app).execute(
""" """
SELECT t.display_name, COUNT(nt.note_id) AS uses SELECT t.display_name, COUNT(*) AS uses
FROM tags t LEFT JOIN note_tags nt ON nt.tag_id = t.id FROM tags t
JOIN note_tags nt ON nt.tag_id = t.id
JOIN notes n ON n.id = nt.note_id AND n.deleted_at IS NULL
GROUP BY t.id ORDER BY uses DESC, t.display_name GROUP BY t.id ORDER BY uses DESC, t.display_name
""" """
).fetchall() ).fetchall()
+12
View File
@@ -198,6 +198,18 @@ class TestQueries:
assert client.get("/micropub?q=category", headers=h).get_json()["categories"] == ["IndieWeb", "python"] assert client.get("/micropub?q=category", headers=h).get_json()["categories"] == ["IndieWeb", "python"]
assert client.get("/micropub?q=category&filter=py", headers=h).get_json()["categories"] == ["python"] assert client.get("/micropub?q=category&filter=py", headers=h).get_json()["categories"] == ["python"]
def test_category_skips_unused_tags(self, client, h):
"""Tags dropped by an edit or on deleted posts aren't offered (v2.12.1)"""
create(client, h, category=["kept"])
retagged = create(client, h, category=["dropped"])
deleted = create(client, h, category=["trashed"])
body = {"action": "update", "url": retagged, "replace": {"category": ["kept"]}}
assert client.post("/micropub", json=body, headers=h).status_code in (200, 204)
assert client.post("/micropub", json={"action": "delete", "url": deleted}, headers=h).status_code == 204
assert client.get("/micropub?q=category", headers=h).get_json()["categories"] == ["kept"]
assert client.post("/micropub", json={"action": "undelete", "url": deleted}, headers=h).status_code < 300
assert client.get("/micropub?q=category", headers=h).get_json()["categories"] == ["kept", "trashed"]
def test_config_lists_queries(self, client, h): def test_config_lists_queries(self, client, h):
config = client.get("/micropub?q=config", headers=h).get_json() config = client.get("/micropub?q=config", headers=h).get_json()
assert "category" in config["q"] and "media-endpoint" in config assert "category" in config["q"] and "media-endpoint" in config