The merge order fails at every run on a bead whose pull request no longer exists #23
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/gascitypacks-ais"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Rebased onto main (
d6a1e66). The only conflict was CHANGELOG.md; the entries now sit under a new### Fixedin the current[Unreleased], and neither released section is touched. The code is unchanged apart from the rebase.What the pull request does:
gc forgejo pr stateprintsmissingfor a pull request the forge answers "not found" for, but only when the 404 carries the forge API's own error object. Any other 404, an unreachable forge and every other error stay a failed run.--pron another host, or one that is not a pull request URL, printsforeignwith no request made; the merge order skips such a bead with one line on stderr and the run does not fail.missingbead the order assigns it to the Operator, mails with--notify(subjectPull request not found: <bead>, saying the pull request does not exist on the forge any more) and records the URL inmetadata.pr_closed, so the next run skips it.The Operator's mail, for a pull request the forge no longer has:
Pull request not found: <bead>Bead <bead> in <rig or the HQ store>: <url> does not exist on the forge any more (it answers "not found"), so the bead cannot follow it to merge. The bead is assigned to you. Ask the user whether to drop it or redo it.Checked after the rebase:
go vetandgo testin forgejo,gc lint .,tests/formula.sh,worktree-setup.sh,worktree.sh,gnu-tools.sh,merge.sh,apply.sh,upgrade.sh,view-beads.sh,view-mail.sh(all pass), and the v1 changelog checker in an ordinary clone of this branch (valid=true).Session facts the Operator asked for:
command -v dateprints/Users/mikluko/.local/share/gascitypacks/gnubin/date.Bead: gascitypacks-ais
Review of
0af2beea: changes required. Not merged.Reviewed against bead gascitypacks-ais. CI for this head is green (run 62: lint, scripts, changelog).
mainis still ata02b60b, the branch's base, so the squash result is the head's tree. On it I ran whattest.yamlruns:gc lint .,tests/formula.sh,go vetandgo testinforgejo, the seven script tests and the changelog check (valid, no release due). All pass, and so do shellcheck and gofmt. What the order does withmissingis right: the bead is handed over once and skipped at the next run, and the mail reads as the description says.One thing must change before this merges (1 and 2), and the changelog entry needs a small fix (3).
1. A 404 that the forge did not write is read as
missing(forgejo/assets/forgejo/main.go:158-161)prStatereportsmissingfor any response with status 404, whoever wrote it. A forge that is down behind a reverse proxy is often answered that way: the proxy has no route to the forge and answers 404 itself. Traefik's Kubernetes providers do so by default when the forge's service has no endpoint available (allowEmptyServices, default false; its reference says that turning it on "results in503HTTP responses instead of404ones"). The bead asks that a forge that cannot be reached stays a failed run. Behind such a proxy it does not.Reproduced on this head with
merge.sh, the pack's tool, the stubgcoftests/merge.sh, three open beads that carry a pull request, and a fake that answers as such a proxy does (404 page not found,text/plain):So one run of the order while the forge restarts takes every open bead that carries a pull request in that store from its holder, mails the Operator that each pull request no longer exists, and exits 0.
pr_closedthen holds the URL, so if that pull request is later closed without merging, the bead is never handed over for it (merge.sh:51). Before this change the same run fails and the next one succeeds.pr statealso printsmissingfor an HTML 404 page and for a 404 with no body. A 502, a 503, a 200 that is not JSON, a 401 and a refused connection fail as they should.Required: report
missingonly when the forge itself answered "not found", and keep every other 404 an error (exit 1, nothing on stdout). The forge's own answer is the API's error object. Forgejo 17 answersGET /repos/<owner>/<repo>/pulls/<n>, for a pull request or a repository it does not have, withContent-Type: application/jsonandOne way, with no second request. I tried it on a copy of this head: the existing tests pass, the body above gives
missing, and404 page not found, an HTML page and an empty 404 give exit 1.Asking the API a second question after a 404 is as good, if you would rather not depend on the body:
GET /api/v1/versionanswers 200, and the pull request is still 404 when read again.2. Tests for it (
forgejo/assets/forgejo/main_test.go)TestPRStateFailsWhenTheForgeDoesNotAnswerWithAPullOrNotFound(line 375) covers a 401 and a refused connection. Add a 404 that the forge did not write, which must exit 1 with nothing on stdout. The fake gives one as it is: its mux has no route for--pr f.srv.URL+"/other/repo/pulls/1"and answers Go's404 page not found, byte for byte what Traefik writes. On this head that case printsmissing. A 5xx case would complete the set.Content-Type: application/json, so that themissingcases at lines 359-360 test what a forge sends.3.
CHANGELOG.md:12-13<bead>in("Pull request not found: <bead>", ...)is outside a code span, and the forge drops it as an HTML tag. Rendered, the entry reads("Pull request not found: ", saying ..., and so would the release notes cut from it. Put the subject in backticks, as the other entries do with<forge>and<bead-id>.Fixedentries makes that list a loose one. Every other section of the file keeps its entries on consecutive lines.Not required
forgejo/orders/merge.toml:2androles/agents/operator/skills/operator/SKILL.md:39still name only a pull request closed unmerged. A word about one the forge no longer has would keep them true.Outside this pull request
pr_urlis not a pull request URL makespr stateexit 2, and the order fails on it at every run, as it did on the missing one. That was so before this change and is worth a bead of its own.Reviewed by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.
0b46266f0ae1ab70b90ee1ab70b90ea46f22dee4Review of
a46f22de: passes. Merged (squash,7ac869b).Reviewed against bead gascitypacks-ais, at
e1ab70bfirst and again after the rebase onto215bcc5. The diff against main is the one reviewed ate1ab70b. Only the CHANGELOG context changed: both bullets of this pull request sit under### Fixedin[Unreleased], after #24's, and the 0.4.0 and 0.5.0 sections are untouched. CI for this head is green (changelog, lint, scripts).On the merge result with
215bcc5(same tree as this head) I ran whattest.yamlruns: the ten scripts undertests/(permission-deny.shamong them),gc lint .,go vetandgo testinforgejo, and the changelog check built from mikluko/changelogv1(valid, no release due). All pass. The new tests fail against main's code, and the not-found tests also fail against this pull request's first commit.What the order does for each state of a pull request:
--notify, and recordspr_closed, so the next run skips the bead.pr_urlon another host, or one that is not a pull request URL:foreign. One line on stderr, no request sent, and the run does not fail.In every case the run goes on to the next bead. The earlier review's findings are all answered: only the forge's own 404 counts as missing, the token goes only to the forge's host, and the CHANGELOG,
merge.tomland the Operator skill wording are fixed.Possible follow-ups, not blocking:
FORGEJO_URLunset, would have every bead skipped asforeign.Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.