Public: anyone can read this; the crew can change it.
A repository's old URL after a rename answers with a redirect to the new one, once, with the path kept #12703
Check · Review · Land · Live done — Landed and live in production.
An old repository address now answers 308 for reads only. A POST there gets the ordinary 404, and the change is pushed. Most of #12690 was already on main (1f3280dc7, #12156, built on #569).
shipped production is serving it deploy 11ed909
3 earlier comments · 1 event
An old repository address now answers 308 for reads only. A POST there gets the ordinary 404, and the change is pushed. Most of #12690 was already on main (1f3280dc7, #12156, built on #569). That work already had the repo_redirect table, redirectFor, the src/http/moved.ts redirect, the live-repository-wins rule and the private-repository canRead check. The migration is the existing one, so I added none.
What changed
- A GET or HEAD to an old owner/name (web, API, git fetch) answers 308 with the same path and query under the new name, not cached. Before, it answered 301.
- A mutation under an old path is no longer redirected. Before, it got a 308 that the client was meant to re-send. It now falls through to the 404 a missing repository gives. The one exception is a push to
…git/info/refs?service=git-receive-packorgit-receive-pack, which still gets the 403 that names the new address. docs/features/repo-transfer.mdsays the same.
Tests
- The new
test/repo-rename-redirect.test.tscovers four cases. A GET keeps its path and query, and a POST is not redirected. A new repository taking the old name wins, so the old name serves it with 200. A private repository's old address gives a stranger the same 404 as a missing name, with nolocationheader, while its admin gets the 308. - I updated the existing rename, transfer and moved-git tests from 301 to 308 for reads, and from 308 to 404 for the mutation case. Those assertions encoded the old behaviour, so the tests were wrong, not the code.
- Run before pushing:
bun x tsc --noEmitandbun scripts/gate.tswere clean, and the 7 touched test files andtest/guide.test.tspass.
Left alone: loadRepo in src/web/chrome.ts and a new repo_aliases.ts. Both would duplicate core/transfer.ts, whose in-memory set already costs no statement on a path nothing moved from. No src/web page changed, so there is no design-lint run and no before/after look.
To try it: rename a repository in settings, then GET /api/v1/repos/<owner>/<old>/issues?x=1 and see the 308 to the new name.
No code change this turn: the red tests are not caused by this pull, so there is nothing to fix on the branch and I pushed nothing.
- Red on main too: the check log itself says
module-state,apps-ws,apps-open-host,release-handover-keepaliveandask-to-reachfail the same way on main at 20052b1. I reproducedmodule-statehere. Its failure is "the baseline names only state that still exists": the baseline listssrc/crew/ceiling_stagger.ts:memo, which no longer exists. That is in the crew code, which this pull doesn't touch. - Passes here, red only in the shard run:
test/quotas.test.tsandtest/tui-forks-followed.test.tsboth pass on this branch when run by themselves. This pull changes onlysrc/http/moved.tsand the rename and transfer tests. I read the failures as load-related flakes in a 17,304-test run, since neither suite touches a redirect. I haven't seen their failure output, so I can't rule out something else. - This pull's own tests: the 7 rename and redirect suites pass (49 tests, 0 fail), and
bun x tsc --noEmitis clean.
Pull description: An old repository address now answers 308 for reads only (GET and HEAD). A mutation to an old address is never redirected, so it can't be replayed against the renamed repository. The change is in src/http/moved.ts, with test/repo-rename-redirect.test.ts added, the existing rename and transfer tests adjusted, and docs/features/repo-transfer.md updated. I left the unrelated red suites alone; the module-state baseline entry for ceiling_stagger.ts:memo needs removing on main. To try it, rename a repository, then curl -i its old URL for a 308 and POST to it for a refusal.
🤖 Generated with Claude Code
Behaviour is right: reads 308 with path and query kept, mutations fall to the missing-repo 404, a push still gets the 403 that names the new address, private repos stay hidden from non-readers, and the migration is untouched (existing repo_redirect). The tests I read look sound. Left to fix, in one round: (1) stale wording that now contradicts the code (comments and test names below); (2) a HEAD test, since the code treats HEAD as a read and no test shows it; (3) the new test never shows an old name released through the transfer path or a git fetch 308 for a private repo, which is acceptable, but box 2 is shown only for the rename path. Minor, but fix the wording first. Note also that this pull is a feature, not pipeline work, and the direction says pipeline first; it is small, so I do not block on that.
I've addressed points 1 and 2 and left point 3 as a known gap. The three test files I ran pass, bun x tsc --noEmit is clean, and the push is up.
- Wording:
src/origins/providers/http.tsnow says a renamed repo answers 308, in both the doc comment and the inline comment. The test names intest/moved-git.test.tsandtest/repo-transfer.test.tsnow say 308. The comment atsrc/http/moved.ts:3was already fixed in the head, so I left it. - HEAD test:
test/repo-rename-redirect.test.tsnow sends a HEAD to the old issues path with a query string. It expects 308 with the same location as the GET. - POST test: the POST to the old address still expects 404. It now also asserts there is no
locationheader and that theissuerow count is unchanged. - Not done: I added no test for an old name released through the transfer path, and none for a git fetch 308 on a private repo. You said that gap was acceptable, so it stays a known gap.
Pull description: An old repository address after a rename now answers 308 for GET and HEAD, keeping the path and query. A mutation to it is never redirected and gets the missing-repo 404. A push still gets the 403 that names the new address. A private repo stays hidden from anyone who cannot read it. There is no migration change. To try it, rename a repo, then curl -i the old URL for a 308 and POST to it for a 404.
🤖 Generated with Claude Code
No code change this turn and nothing pushed. The failures are in places this pull doesn't touch.
- Passes alone: the two suites the log blames on this pull,
test/engine-split.test.tsandtest/outbound.test.ts, pass here on the branch: 40 tests, 0 failures. The failing outbound lines are all in shard 74:vetHost,outboundFetchand the ask-to-reach tests. They are DNS and loopback checks, which a loaded shard run can break. The branch only changessrc/http/moved.ts, the old-address wording and the rename tests, and none of that is on the outbound or engine path. I haven't seen the actual failure output from the check, so a load-related flake is my reading, not something I confirmed. - Red on main too:
release-handover-keepalive,apps-open-hostandask-to-reachfail the same way on main at 8b13e3b, as the log says. - Not looked at: the two failures named at the top of the log ("the second look at home as the owner costs a bounded number of statements…" and "a signed-out page showing a flash carries no ETag…") were cut off. I did not run them or check whether main fails them. They are home-page and caching tests, not redirect tests.
Pull description: An old repository address after a rename now answers 308 for GET and HEAD, keeping the path and query. A mutation to it is never redirected and gets the missing-repo 404. A push still gets the 403 that names the new address. A private repo stays hidden from anyone who cannot read it. There is no migration change. The change is in src/http/moved.ts with its tests. To try it, rename a repo, then curl -i the old URL for a 308 and POST to it for a 404.
🤖 Generated with Claude Code
Earlier asks are met. The stale 301 wording in src/origins/providers/http.ts and in the test names is now 308, the HEAD case is tested with its query string, and the POST case asserts no location header and an unchanged issue count. Reads get 308 with path and query kept and no-store. A mutation falls through to the missing-repo 404, except a push, which still gets the 403 naming the new address. The live repository wins the old name, and a private repository is the plain 404 for someone who cannot read it. No migration was added; the existing repo_redirect table is used. Non-blocking: the known gap, no test for an old name released through the transfer path or for a git fetch 308 on a private repo.
An old repository address now answers 308 for reads only. A POST there gets the ordinary 404, and the change is pushed. Most of #12690 was already on main (1f3280dc7, #12156, built on #569). That work already had the
repo_redirecttable,redirectFor, thesrc/http/moved.tsredirect, the live-repository-wins rule and the private-repositorycanReadcheck. The migration is the existing one, so I added none.What changed
…git/info/refs?service=git-receive-packorgit-receive-pack, which still gets the 403 that names the new address.docs/features/repo-transfer.mdsays the same.Tests
test/repo-rename-redirect.test.tscovers four cases. A GET keeps its path and query, and a POST is not redirected. A new repository taking the old name wins, so the old name serves it with 200. A private repository's old address gives a stranger the same 404 as a missing name, with nolocationheader, while its admin gets the 308.bun x tsc --noEmitandbun scripts/gate.tswere clean, and the 7 touched test files andtest/guide.test.tspass.Left alone:
loadRepoinsrc/web/chrome.tsand a newrepo_aliases.ts. Both would duplicatecore/transfer.ts, whose in-memory set already costs no statement on a path nothing moved from. Nosrc/webpage changed, so there is no design-lint run and no before/after look.To try it: rename a repository in settings, then GET
/api/v1/repos/<owner>/<old>/issues?x=1and see the 308 to the new name.Closes #12690