Skip to content

v4 release flow: a hotfix release force-resets next to master, dropping next's queued commits and auto-closing the next→master release PR (silent data loss) #278

Closed

Description

@Shinrai

Summary

When a hotfix release (hotfixes → master) merges, the post-release automation force-resets next to master. Because a hotfix ships only its own commits — not whatever is queued on next — this discards every commit that was queued-but-unreleased on next, and then auto-closes the queued next → master release PR because its diff is now empty.

This is silent data loss: the queued work vanishes from all branches and its release PR closes as if it had shipped, when in fact nothing of it shipped.

Concrete occurrence (CLDMV/gh-broker)

Timeline:

  1. PR docs(embedded-tests): surface the embedded-tests-ci feature in onboarding #43 (fix/... → next) merged into next, advancing it to 6625426 (which carried the v0.2.5 version bump). This created the queued next → master release PR fix(v4): per-branch merge methods + PR-ref annotation in release-PR changelogs #44 (v0.2.5).
  2. Separately, a Dependabot security bump went via hotfixes, creating hotfix release PR docs(readme): modernize for v4; drop stale v3-launch markers; fix ruleset-generator links #46 (hotfixes → master) — also labeled v0.2.5.
  3. docs(readme): modernize for v4; drop stale v3-launch markers; fix ruleset-generator links #46 merged to master → master = 6902569 (v0.2.5), shipping only the hotfix's deps bump.
  4. Post-release automation force-updated next — reflog:
    origin/next: 6625426  →  6902569   "forced-update"
    
    This discarded 6625426 and everything unique to it (all of docs(embedded-tests): surface the embedded-tests-ci feature in onboarding #43's commits: 861ca99, a3c2247, fadfd29).
  5. next now equals master (0 commits ahead), so the bot auto-closed release PR fix(v4): per-branch merge methods + PR-ref annotation in release-PR changelogs #44 as having nothing to release.

After the fact, #43's commits are on no branch — master, next, and hotfixes all point at 6902569, none of which contain them. They survive in this repo only because a separate in-flight feature branch happened to be forked from next while #43 was on it; absent that coincidence the work would have been recoverable only via reflog/SHA archaeology.

Root cause

The post-release next sync is a hard reset of next to master. That is only ever safe after a next → master release, where next's commits actually shipped to master. After a hotfix release, next still holds unrelated queued commits that did not ship, and resetting drops them.

Contributing factor — version collision: both the queued release PR (#44) and the hotfix release PR (#46) were assigned v0.2.5. The hotfix consumed the version, making the queued PR's version moot and its post-reset diff empty, which is what triggered the auto-close.

Recommended fix

  1. After a hotfix release, MERGE master into next (or rebase next onto master) — never hard-reset next to master. The merge brings the hotfix into next while preserving next's queued commits. Reserve the reset-style sync for next → master releases only (and even there, a merge is safer).
  2. Don't hand the same version to a concurrent hotfix and next release. The version resolver should account for an in-flight hotfix so the queued next release doesn't collide on the same X.Y.Z.
  3. Guard the release-PR auto-close: only auto-close a next → master release PR when its content genuinely shipped to master (its head commits are ancestors of the new master tag), not merely because next was reset to equal master.

Impact / severity

High — this is a silent data-loss path that fires whenever a hotfix ships while next has queued work. The queued commits disappear from every branch and the release PR closes as if released. It affects every consumer using the v4 next/hotfixes staging flow, not one repo.

Notes

Filed from CLDMV/gh-broker (release PRs #44 vs #46, feature PR #43). Related but distinct from #275 (the vars-in-composite CI break). Reflog evidence and orphaned-tip SHA (6625426) available on request.

Activity

  1. added
    type: bug
    priority: critical
    status: confirmed
    type: ci
    on Sep 6, 2026
  2. added theissue type on Sep 6, 2026
  3. Shinrai commented on Sep 6, 2026

    @Shinrai
    ContributorAuthor

    Triaged as a confirmed, critical data-loss bug (Bug / priority: critical), verified against the release-flow code and the gh-broker incident.

    One correction to the framing worth recording: recommended fix #1 is already implemented and shipped. Since v4.16.11 (#169), workflow-next-reset.yml determines the released lane from the squash commit's trailing (#N) → PR head ref and, for a hotfix release, merges master into next (via merge-master-into-branch) instead of force-resetting — preserving next's queued work. It's on the current @v4, so "always reset" is no longer the happy path.

    That leaves three real, still-live gaps:

    1. Lane detection fails open to the destructive path. In workflow-next-reset.yml (the "Determine released lane" step), the lane is hotfix only when gh pr view <N> --json headRefName returns exactly hotfixes. On any lookup failure (auth / rate-limit / mis-parsed (#N) — the error is swallowed by 2>/dev/null || echo "") it falls through to lane=other, which force-resets next. The safe default must be the preserve path (merge), never the reset. This is the most likely proximate cause of the gh-broker occurrence — next shows a plain forced-update, not a merge commit.

    2. Version collision (fix Min version not set in publish causes multiple tests to run #2) — unaddressed. npm/steps/resolve-version has no awareness of an in-flight hotfix, so a queued next release and a concurrent hotfixes release can both resolve to the same X.Y.Z (fix(v4): per-branch merge methods + PR-ref annotation in release-PR changelogs #44 and docs(readme): modernize for v4; drop stale v3-launch markers; fix ruleset-generator links #46 both → v0.2.5). How the resolver should learn the in-flight hotfix version at resolve time is an open design question.

    3. Release-PR auto-close (fix release/v3.0.0 #3) — unaddressed / partly GitHub-native. fix(v4): per-branch merge methods + PR-ref annotation in release-PR changelogs #44 closed because after the reset next == master (0 ahead), which GitHub itself treats as fully-merged and closes. Fixing gap 1 removes the trigger; a belt-and-braces guard is still worth adding.

    Fix scope and the design decision for #2 to follow before opening a PR.

  4. Shinrai commented on Sep 6, 2026

    @Shinrai
    ContributorAuthor

    Root cause confirmed from the reset run's logs (gh-broker run 34014340050, the reset fired when #46 merged). Correcting my earlier note: fix #1's merge path exists but never executed — it has been dead code on every hotfix release.

    The "Determine released lane" step logged:

    released PR #46 head ref: <unknown>
    

    prnum parsed correctly as 46, but gh pr view 46 --json headRefName returned empty, so head="" → lane=other → the "Ensure next = master HEAD (normal release)" force-reset ran (✅ Force-reset complete via API. next → 6902569). Steps 8/9 (the hotfix merge) were skipped.

    Why the PR read returned nothing: workflow-next-reset.yml's app-token step requests permission_contents + permission_workflows only. create-app-token switches to fine-grained mode as soon as any permission flag is set, granting only the requested scopes — so the token has no pull_requests permission, and gh pr view is silently denied (the error is swallowed by 2>/dev/null || echo ""). Net: lane detection resolves to other for every hotfix release, the merge path never runs, and next is force-reset — this exact data loss, on any repo with queued work on next.

    Two independent defects, either alone sufficient to cause it:

    1. Token missing pull_requests scope → lane detection can't read the PR head → always other.
    2. Lane detection fails open to the destructive path (unknown head → force-reset) and swallows the error that would have revealed Fix Workflow publish #1.

    Fix plan (one PR into next):

    • Add permission_pull_requests: "true" to the token step (revives the merge path).
    • Guard the reset itself: never force-reset next when it holds commits not already on master — merge instead — so data loss is impossible regardless of lane detection. Stop swallowing the gh error.

    Version collision (fix #2) and the auto-close guard (fix #3) remain separate follow-ups.

  5. cldmv-bot commented on Sep 6, 2026

    @cldmv-bot
    Contributor

    Closed in v4.26.2 — resolved by #278.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: criticalstatus: confirmedtype: bugtype: ci

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions