Draft release's tag_name never updates after first creation, even when a later PR should escalate the bump type #44

Closed
opened 2026-09-30 22:38:38 +02:00 by ai-bot · 0 comments
Member

Found while debugging why Aevana/aevana's releases always seemed to end up as patch bumps regardless of what merged.

The bug

release_drafter.py, create_or_update_release():

tag = existing_draft.get("tag_name") if existing_draft else new_tag

generate_next_tag() does recompute the correct bump type (major/minor/patch, from breaking-change/feature labels on every merged PR since the last real release) on every single run. But create_or_update_release() only ever uses that fresh value on the initial POST (when no draft exists yet). Every subsequent run is a PATCH, and the PATCH path discards new_tag and reuses existing_draft["tag_name"] — only body/name get refreshed, tag_name is frozen at whatever it was on first creation.

Concrete failure mode

  1. PR A (labeled fix) merges first after the last publish → draft created as v1.2.4 (patch).
  2. PR B (labeled feature) merges before anyone publishes the draft → generate_next_tag() correctly computes v1.3.0, but create_or_update_release() throws it away and keeps v1.2.4.
  3. Draft gets published as v1.2.4 even though it contains a real feature — undercounting the actual scope of the release, silently, every time.

In practice this means the drafter's bump-type logic only ever matters for whichever PR happens to land first in a release window — every later PR's labels are computed but never acted on.

Suggested fix (my recommendation, not the only option — happy to be overruled)

Just stop discarding the fresh value:

tag = new_tag

Same PATCH call already fires every run (to refresh body), so this costs nothing extra — it just lets tag_name/name get the same "always reflect current truth" treatment the notes already get.

I'd specifically recommend against an alternative I was asked to weigh in on — delete the existing draft and create a fresh one whenever the newly computed tag is semver-"bigger" than the existing draft's tag. That works, but:

  • It discards the draft's id/URL on every escalation, breaking any link/bookmark someone has open on it mid-review, for no benefit.
  • It needs actual semver-comparison logic (parse both tags, compare) just to decide when to replace — extra surface for a problem the plain-overwrite fix doesn't have.
  • It only self-corrects upward. If a merged PR's labels are ever edited after the fact (label added late, or a PR gets un-merged/re-merged), a "smaller" recompute would never take effect, whereas tag = new_tag always reflects whatever the current true computation is, in either direction.

Depends on

Nothing — self-contained fix to this repo. Downstream consumer for context: Aevana/aevana, where this surfaced.

Found while debugging why `Aevana/aevana`'s releases always seemed to end up as patch bumps regardless of what merged. ## The bug `release_drafter.py`, `create_or_update_release()`: ```python tag = existing_draft.get("tag_name") if existing_draft else new_tag ``` `generate_next_tag()` *does* recompute the correct bump type (major/minor/patch, from `breaking-change`/`feature` labels on every merged PR since the last real release) on every single run. But `create_or_update_release()` only ever uses that fresh value on the initial `POST` (when no draft exists yet). Every subsequent run is a `PATCH`, and the `PATCH` path discards `new_tag` and reuses `existing_draft["tag_name"]` — only `body`/`name` get refreshed, `tag_name` is frozen at whatever it was on first creation. ## Concrete failure mode 1. PR A (labeled `fix`) merges first after the last publish → draft created as `v1.2.4` (patch). 2. PR B (labeled `feature`) merges before anyone publishes the draft → `generate_next_tag()` correctly computes `v1.3.0`, but `create_or_update_release()` throws it away and keeps `v1.2.4`. 3. Draft gets published as `v1.2.4` even though it contains a real feature — undercounting the actual scope of the release, silently, every time. In practice this means the drafter's bump-type logic only ever matters for whichever PR happens to land *first* in a release window — every later PR's labels are computed but never acted on. ## Suggested fix (my recommendation, not the only option — happy to be overruled) Just stop discarding the fresh value: ```python tag = new_tag ``` Same `PATCH` call already fires every run (to refresh `body`), so this costs nothing extra — it just lets `tag_name`/`name` get the same "always reflect current truth" treatment the notes already get. I'd specifically recommend **against** an alternative I was asked to weigh in on — delete the existing draft and create a fresh one whenever the newly computed tag is semver-"bigger" than the existing draft's tag. That works, but: - It discards the draft's `id`/URL on every escalation, breaking any link/bookmark someone has open on it mid-review, for no benefit. - It needs actual semver-comparison logic (parse both tags, compare) just to decide *when* to replace — extra surface for a problem the plain-overwrite fix doesn't have. - It only self-corrects upward. If a merged PR's labels are ever edited after the fact (label added late, or a PR gets un-merged/re-merged), a "smaller" recompute would never take effect, whereas `tag = new_tag` always reflects whatever the current true computation is, in either direction. ## Depends on Nothing — self-contained fix to this repo. Downstream consumer for context: `Aevana/aevana`, where this surfaced.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Wi3eDigital/forgejo-release-drafter-action#44
No description provided.