Repository navigation
fix(githttp): answer a delete of a ref that the replica does not list - #928
Conversation
…oes not list git sends `git push <remote> :<ref>` as a command from the zero id to the zero id when the replica's cache does not list the ref. Stock git's receive-pack answers it with ok and the warning "deleting a non-existent ref". The update hook swaps nothing to nothing in the ref store, which is an assertion there, and the pusher reads only "hook declined". The test runs the command against a ref that no store holds and against one that the store holds, on every lane (PostgreSQL, local and S3-WAL), and fails on main. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->
git sends `git push <remote> :<ref>` as a command from the zero id to the zero id when the replica's cache does not list the ref, and a client can send it for any ref. The update hook passed it to the ref store, where a swap from nothing to nothing is an assertion, so the push ended in "hook declined" and a Go panic in the log. The hook now answers the command from the ref store. When the store holds no such ref, the command is a delete of a ref that does not exist, which stock git answers with ok and a warning, and so does the hook. When the store holds the ref, the pusher's belief that it is absent is wrong (the replica's cache lags, or the ref was created since the client read the refs), so the hook refuses the command with a per-ref ng that names the ref and its SHA, and writes an operator line to the hook-errors file. A failed read is a hook failure that the pusher reads as a generic line. The runbook step for a ref pair in another namespace said that the push fails. It now says what the replica answers. The git protocol page and the monitoring table name the new line. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->
… absent ref --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->
…usal Change-Id: I83d590f52987284a0c6d29125bef2bf78bd837fd Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis 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. 🚀 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. |
…o answer A verifier found that the operator line could lose its sha and cause fields and that the zero-to-zero condition could be widened to one of its two halves, and that no test of the pull request failed on either. A test now runs a create, a delete and zero-to-zero commands through the real update hook and counts the swaps, and the operator line test names every field. The git protocol page says that an atomic push with such a command is refused whole by pre-receive, and that the remote text names the ref and the first 8 hex digits of the SHA. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->
…usal Change-Id: Ia4de684eee91d47f9cc81fbec16de1ebb41c9bc1 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Nice work! 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. |
Why
git push <remote> :<ref>through a replica whose cache does not list the ref reaches the update hook as a command from the zero id to the zero id. Stock git sends exactly that:git push o :refs/notes/a, for a ref that the remote does not advertise, makes the client send0000... 0000... refs/notes/a, and stock receive-pack answers it withokand the warningdeleting a non-existent ref(checked with git 2.53). A client can also send it for any ref by hand.The hook gave the command to the ref store, where a swap from nothing to nothing is an assertion in every store (
casRef). The hook panicked. The pusher read only the genericupdate failed; push again later (the server log has the cause)and git'shook declined, and the log held a Go trace. Found while verifying #917, whose runbook says that this push fails.What changed
updateHook(internal/githttp/hook.go): a command with old and new both zero is answered by the newanswerDeleteOfAbsentRef, after the ref policy, the hold and the sync fence, and before the swap. It reads the ref once from the ref store (GetRef, a point read that every store has):ng(hook declined) whoseremote:text names the ref and the first 8 hex digits of its SHA (update: <ref> exists at <sha> in the ref store, but this replica does not list it: fetch, then push the delete again) and writes a WARN line to the hook-errors file, whichservelogs (ref,sha,cause). The ref stays. Stock git would delete an existing ref here, because it reads a zero old value as "no value to check". The hook cannot do that: the ref policy ran with old = zero, so a policy that decides on the value that a delete removes (no-force-push, for one) has not seen it.git-protocol-and-namespaces.mdlists the answer, and the monitoring table and the metrics mapping indeploy-production.mdlist the operator line.updateHookis covered,answerDeleteOfAbsentRefis new). The model does not describe the zero-to-zero command.Tests
TestDeleteOfAnAbsentRefIsAnsweredNotCrashed(e2e, runs on every lane): a zero-to-zero command for a tag, a branch and a notes ref that no store holds answers ok and writes nothing, the same command for a notes ref that the store holds answersngwith the ref and SHA in the pusher's text and the operator line (ref,sha,cause) inserve's log and leaves the ref, and ano-pushpolicy still refuses. It is red on main on all three lanes: the first head of this PR held only this test, and CI failedtest(PostgreSQL),test-localandtest-s3walon its four subtests (a tag that no store holds,a branch ...,a notes ref that no store holds,a notes ref that the ref store holds).TestUpdateHookAnswersAZeroToZeroCommandruns the real update hook on a SQLite store (red on main:update failed; push again later), andTestAnswerDeleteOfAbsentRefOnEachStoreruns the answer on SQLite and on S3-WAL with an in-memory conditional store, including a failed read. PostgreSQL runs in the e2e test.TestUpdateHookSwapsEveryCommandThatIsNotZeroToZeroruns a create, a delete and zero-to-zero commands through the real hook and counts the swaps: only zero-to-zero is answered without one.Mutants that each fail a test: the absent answer refused, the held answer ok, a read error ignored, no operator line, the line without
shaandcause, the condition widened toold == zeroonly ornew == zeroonly, the call moved before the policy check, and the branch removed (main's behavior).Evidence at the head (404ac51): CI is green (
test,test-local,test-s3wal, lint, both fingerprint gates).go test -race ./internal/githttpon the local backend passed at 2dbe03d (857 s), and the commits since change a test and docs only. Codex code and security reviews of the head found nothing. A read-only verifier that I did not brief on the fix ran its own probes and answeredVERDICT #928 404ac51a PASS. Its earlier round on 2dbe03d found wording and test gaps, which 37c86c0 closes.Limits
--atomic, pre-receive refuses the whole push first, as for any command whose old value the store contradicts (<ref> already exists (created concurrently); fetch first), with no SHA and no operator line.Generated with
xum• Model:anthropic:claude-sonnet-5-5• Thinking:xhigh