Repository navigation
feat(api)!: answer failed merge guards with 409 ref_guard_failed - #571
Conversation
Refs #568 _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_ Change-Id: Id3704634ec263d38bd926e07c6fb6533124ebf29 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
1 similar comment
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
A failed merge guard now answers 409 with code
ref_guard_failedand two new members:guardandcurrent_sha. A merge withexpected_source_shawhose source branch does not exist now fails that guard (409,current_sha40 zeros) instead of answering 404. This is PR 1 of 2 for #568. PR 2 adds the problem members to the notes 409s.What
POST /api/v1/repos/mergeandPOST /api/repos/{repo_name}/merge, staleexpected_target_sha: 409 with coderef_guard_failed,guard: expected_target_shaandcurrent_sha= the target tip. Before, the code wasconflictwith noguardorcurrent_sha.expected_source_sha: 409ref_guard_failed,guard: expected_source_sha,current_sha= the source tip.expected_source_shaset and the source branch missing: 409ref_guard_failedwithcurrent_sha40 zeros. Before, this was 404. Withoutexpected_source_sha, a missing source branch is still 404. The target lookup and the target guard still run first.detailanderrortext do not change. Nothing else changes: the content type staysapplication/json(the api: problem-details later tiers (specific codes, instance, result envelope, git/LFS writers, problem+json) — held on SDK trigger #352 SDK gate has not fired), and every other route keeps its status and code.errors.go:ref_guard_failed(409) joins the specific-code map. One new writer sends it, andwriteProblemasserts that the code always carries both members and that no other code carries them.Why
The upstream docs OpenAPI of 2026-10-27 (
c494c01b) adds the specific coderef_guard_failedwith the schemaRefGuardProblemDetailsand says that the merge guards use it. The Oct 22 changelog already said that a deleted source branch answers 409. Vendoring the spec alone failsTestSpecificProblemCodesMatchUpstream, so the spec, the code map and the first behavior change land together.Snapshot
docs/upstream/openapi.yamlis the audit copy of the docs spec: Last-Modified 2026-10-27 21:25:57 GMT, ETagW/"BXslwivBc1LQOzE_", SHA-256c494c01b2299053d8e6591a4aa794e65d2e38859407da6d320322d9f0d0119d0.10f3e009(the previous snapshot), so the change is documented in the docs only.b598ce96…). Its only change is twomessagedescriptions on commit lists and files/metadata. I did not widen this PR. Upstream drift (spec 2026-10-27 21:45): commit list and files/metadata messages are the subject line only; spec b598ce96 #570 tracks that revision.Not in this PR
POST .../notes/appendand theDELETE .../notesquery form: their 409 gets the problem members in PR 2.Proof
conflictor 404. With the fix they pass.TestProblemMembersMatchUpstreamnow pinsguardandcurrent_shaand theguardenum toRefGuardProblemDetailsin the vendored spec. The shared oracle (assertProblemFields) accepts those two members only on coderef_guard_failed, and there it requires both: a guard from the spec enum and a 40-hexcurrent_sha.current_sha, the old 404 for a missing source, a droppedguardmember, a renamedcurrent_shamember, the code-map entry removed, the source guard ahead of the target guard, the spec without theref_guard_faileditem, an extra value in the spec'sguardenum, and an oracle that expectsconflict.go test -race ./internal/api/...ok (PostgreSQL and SQLite), golangci-lint v2.15.0 (the mise.toml pin) 0 issues, and the docs gate (0 broken links, the link-checker tests pass).TestMerge_ExpectedSourceSHApasses on the local lane. The PostgreSQL and S3-WAL lanes did not start on my host: its disk is full, so SeaweedFS refused writes in TestMain before any test ran. The requiredtestandtest-s3walCI jobs run that test on this head.Refs #568
BREAKING CHANGE: a failed merge guard on POST /api/v1/repos/merge and POST /api/repos/{repo_name}/merge now answers code ref_guard_failed instead of conflict, with guard and current_sha members. A merge with expected_source_sha whose source branch does not exist answers 409 ref_guard_failed with current_sha 40 zeros instead of 404. Clients that branch on code conflict for a merge guard must check ref_guard_failed.
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high