Skip to content

fix(backstage-template-execution): a PR merged by hand is merged, not refused - #69

Merged
patrick-hermann-sva merged 1 commit into
mainfrom
fix/merge-already-merged
Oct 21, 2026
Merged

patrick-hermann-sva merged 1 commit into
mainfrom
fix/merge-already-merged

Conversation

@patrick-hermann-sva

Copy link
Copy Markdown
Contributor

Seen on stuttgart-things#3911 (cutover3, 2026-10-21): the build PR was merged by hand while Deploy-VMs was still running. When the run went green, MergePullRequest found no open PR and refused (no open PR found for branch vsphere-vm-cutover3-labda). The result was a merge-refused card (error) and a FAILED instance, for a VM that was built and on main.

Fix: with no open PR, the gate looks up the PR:

  • by number, from the watched run (MergeInput.PRNumber, new, optional);
  • else the newest closed PR of the branch (GateAndMergeWorkflow path).

If it is merged, the step succeeds and pitches merged with "PR #N was already merged by (by hand)". MergeResult gains byHand / mergedBy. A PR closed without merge stays a refusal. List and merge calls now go through githubAPI like the check gate, so the path is testable.

Tests: main_merged_test.go covers merged by number, merged by branch (no by-number call), closed-unmerged → error, and no PR at all → error. In all four, the gate never PUTs a merge. go vet and go test ./... are green.

Rollout: the workflow's activity sequence is unchanged; only the activity's input gains a field, so in-flight runs replay fine.

🤖 Generated with Claude Code

https://claude.ai/code/session_016TtmNGbCHXQGtqnrT926ZN

… refused

On stuttgart-things#3911 (2026-10-21) the build PR was merged by hand while
Deploy-VMs was still running. When the run went green the gate found no
open PR and refused ("no open PR found for branch ..."): a merge-refused
card in Teams and a FAILED instance for a VM that was built and on main.

With no open PR the gate now looks up the run's PR (by number, from the
watched run; else the newest closed PR of the branch). Merged -> success,
pitched as `merged` with "was already merged by <login> (by hand)". Closed
without merge stays a refusal. List and merge calls go through githubAPI
so the path is testable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016TtmNGbCHXQGtqnrT926ZN
@patrick-hermann-sva
patrick-hermann-sva merged commit 5ee8cfd into main Oct 21, 2026
8 checks passed
@patrick-hermann-sva
patrick-hermann-sva deleted the fix/merge-already-merged branch October 21, 2026 07:57

This branch was successfully deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant