codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

fix(api): delete the repository when an API migration fails (v17) #255

Merged
pat-s merged 2 commits from pat-s/fix-migrate-api-cleanup-orphan-v17 into v17.0/forgejo-codefloe 2026-11-07 10:01:27 +00:00 AGit
Owner

Summary

Port of arbinel/arbinel#30 to v17, which is the branch codefloe.com builds from.

Why

MigrateRepository returns a nil repository on failure, and assigning that to repo made the deferred delete in POST /api/v1/repos/migrate skip its if repo != nil guard.
The API path creates no task, so nothing can finish or retry such a repository: its subpages redirect to the home page, which breaks the repository switcher, and SSH fails with an internal error while HTTPS keeps working.
Production had 17 repositories in this state, reported in forum topic 232; all of them have been repaired by hand.

What

  • A failed POST /api/v1/repos/migrate now deletes the repository it created, as the existing cleanup intended, including when the git data had already landed.
  • Add a README custom changes row.
Context

The regression test replays the reported failure: a Gitea-type migration whose source token lacks read:issue, which fails after the git data was imported.
It fails without the fix on this branch, because the repository survives; TestAPIRepoMigrateConflict still passes.

This only covers migrations that return an error.
A process killed mid-migration runs no deferred cleanup, so it can still leave a repository in this state: krmbzds/jumpstart-pro-rails left no failure notice and may be such a case, though that is unconfirmed.

Written with Claude Code (Opus 5.5).
Only the two migration tests were run locally.

🤖 Generated with Claude Code

## Summary Port of [arbinel/arbinel#30](https://codefloe.com/arbinel/arbinel/pulls/30) to v17, which is the branch codefloe.com builds from. ## Why `MigrateRepository` returns a nil repository on failure, and assigning that to `repo` made the deferred delete in `POST /api/v1/repos/migrate` skip its `if repo != nil` guard. The API path creates no task, so nothing can finish or retry such a repository: its subpages redirect to the home page, which breaks the repository switcher, and SSH fails with an internal error while HTTPS keeps working. Production had 17 repositories in this state, reported in [forum topic 232](https://forum.codefloe.com/t/repository-switcher-returns-html-and-ssh-fails-for-caniko-ai-skills/232); all of them have been repaired by hand. ## What - A failed `POST /api/v1/repos/migrate` now deletes the repository it created, as the existing cleanup intended, including when the git data had already landed. - Add a README custom changes row. <details> <summary>Context</summary> The regression test replays the reported failure: a Gitea-type migration whose source token lacks `read:issue`, which fails after the git data was imported. It fails without the fix on this branch, because the repository survives; `TestAPIRepoMigrateConflict` still passes. This only covers migrations that return an error. A process killed mid-migration runs no deferred cleanup, so it can still leave a repository in this state: `krmbzds/jumpstart-pro-rails` left no failure notice and may be such a case, though that is unconfirmed. Written with Claude Code (Opus 5.5). Only the two migration tests were run locally. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(api): delete the repository when an API migration fails (v17)
Some checks failed
testing / backend-checks (pull_request) Has been cancelled
testing / frontend-checks (pull_request) Has been cancelled
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (1/2) (pull_request) Has been cancelled
testing / test-e2e (2/2) (pull_request) Has been cancelled
testing / test-pgsql (1/4) (pull_request) Has been cancelled
testing / test-pgsql (2/4) (pull_request) Has been cancelled
testing / test-pgsql (3/4) (pull_request) Has been cancelled
testing / test-pgsql (4/4) (pull_request) Has been cancelled
b1fac11eaf
## Summary

Port of [arbinel/arbinel#30](arbinel/arbinel#30) to v17, which is the branch codefloe.com builds from.

## Why

`MigrateRepository` returns a nil repository on failure, and assigning that to `repo` made the deferred delete in `POST /api/v1/repos/migrate` skip its `if repo != nil` guard.
The API path creates no task, so nothing can finish or retry such a repository: its subpages redirect to the home page, which breaks the repository switcher, and SSH fails with an internal error while HTTPS keeps working.
Production had 17 repositories in this state, reported in [forum topic 232](https://forum.codefloe.com/t/repository-switcher-returns-html-and-ssh-fails-for-caniko-ai-skills/232); all of them have been repaired by hand.

## What

- A failed `POST /api/v1/repos/migrate` now deletes the repository it created, as the existing cleanup intended, including when the git data had already landed.
- Add a README custom changes row.

<details>
<summary>Context</summary>

The regression test replays the reported failure: a Gitea-type migration whose source token lacks `read:issue`, which fails after the git data was imported.
It fails without the fix on this branch, because the repository survives; `TestAPIRepoMigrateConflict` still passes.

This only covers migrations that return an error.
A process killed mid-migration runs no deferred cleanup, so it can still leave a repository in this state: `krmbzds/jumpstart-pro-rails` left no failure notice and may be such a case, though that is unconfirmed.

Written with Claude Code (Opus 5.5).
Only the two migration tests were run locally.

</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)
pat-s force-pushed pat-s/fix-migrate-api-cleanup-orphan-v17 from b1fac11eaf
Some checks failed
testing / backend-checks (pull_request) Has been cancelled
testing / frontend-checks (pull_request) Has been cancelled
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (1/2) (pull_request) Has been cancelled
testing / test-e2e (2/2) (pull_request) Has been cancelled
testing / test-pgsql (1/4) (pull_request) Has been cancelled
testing / test-pgsql (2/4) (pull_request) Has been cancelled
testing / test-pgsql (3/4) (pull_request) Has been cancelled
testing / test-pgsql (4/4) (pull_request) Has been cancelled
to f13dc808e4
Some checks failed
testing / frontend-checks (pull_request) Successful in 1m56s
testing / test-pgsql (3/4) (pull_request) Successful in 11m11s
testing / backend-checks (pull_request) Successful in 7m25s
testing / test-e2e (1/2) (pull_request) Failing after 2m46s
testing / test-e2e (2/2) (pull_request) Successful in 3m54s
testing / test-pgsql (2/4) (pull_request) Successful in 7m54s
testing / test-unit (pull_request) Successful in 8m23s
testing / test-pgsql (1/4) (pull_request) Successful in 10m59s
testing / test-pgsql (4/4) (pull_request) Successful in 10m27s
2026-11-06 10:19:27 +00:00
Compare
pat-s scheduled this pull request to auto merge when all checks succeed 2026-11-06 10:24:13 +00:00
pat-s force-pushed pat-s/fix-migrate-api-cleanup-orphan-v17 from f13dc808e4
Some checks failed
testing / frontend-checks (pull_request) Successful in 1m56s
testing / test-pgsql (3/4) (pull_request) Successful in 11m11s
testing / backend-checks (pull_request) Successful in 7m25s
testing / test-e2e (1/2) (pull_request) Failing after 2m46s
testing / test-e2e (2/2) (pull_request) Successful in 3m54s
testing / test-pgsql (2/4) (pull_request) Successful in 7m54s
testing / test-unit (pull_request) Successful in 8m23s
testing / test-pgsql (1/4) (pull_request) Successful in 10m59s
testing / test-pgsql (4/4) (pull_request) Successful in 10m27s
to 2868fab0e0
Some checks failed
issue-labels / backporting (pull_request_target) Has been skipped
issue-labels / cascade (pull_request_target) Has been skipped
testing / test-e2e (2/2) (pull_request) Has been skipped
testing / test-e2e (1/2) (pull_request) Has been skipped
testing / test-pgsql (3/4) (pull_request) Has been skipped
testing / test-pgsql (1/4) (pull_request) Has been skipped
testing / frontend-checks (pull_request) Successful in 1m47s
testing / backend-checks (pull_request) Failing after 2m10s
testing / test-pgsql (4/4) (pull_request) Has been skipped
testing / test-unit (pull_request) Has been skipped
testing / test-pgsql (2/4) (pull_request) Has been skipped
2026-11-07 08:56:52 +00:00
Compare
pat-s force-pushed pat-s/fix-migrate-api-cleanup-orphan-v17 from 2868fab0e0
Some checks failed
issue-labels / backporting (pull_request_target) Has been skipped
issue-labels / cascade (pull_request_target) Has been skipped
testing / test-e2e (2/2) (pull_request) Has been skipped
testing / test-e2e (1/2) (pull_request) Has been skipped
testing / test-pgsql (3/4) (pull_request) Has been skipped
testing / test-pgsql (1/4) (pull_request) Has been skipped
testing / frontend-checks (pull_request) Successful in 1m47s
testing / backend-checks (pull_request) Failing after 2m10s
testing / test-pgsql (4/4) (pull_request) Has been skipped
testing / test-unit (pull_request) Has been skipped
testing / test-pgsql (2/4) (pull_request) Has been skipped
to a4e36184bc
Some checks failed
testing / test-e2e (1/2) (pull_request) Has been skipped
testing / test-unit (pull_request) Has been skipped
testing / frontend-checks (pull_request) Successful in 2m11s
testing / backend-checks (pull_request) Failing after 2m33s
testing / test-e2e (2/2) (pull_request) Has been skipped
testing / test-pgsql (2/4) (pull_request) Has been skipped
testing / test-pgsql (3/4) (pull_request) Has been skipped
testing / test-pgsql (1/4) (pull_request) Has been skipped
testing / test-pgsql (4/4) (pull_request) Has been skipped
2026-11-07 09:01:23 +00:00
Compare
pat-s canceled auto merging this pull request when all checks succeed 2026-11-07 09:19:54 +00:00
Merge remote-tracking branch 'origin/v17.0/forgejo-codefloe' into fix/migrate-api-cleanup-orphan-v17
All checks were successful
testing / frontend-checks (pull_request) Successful in 3m0s
testing / test-pgsql (2/4) (pull_request) Successful in 6m23s
testing / test-pgsql (3/4) (pull_request) Successful in 8m52s
issue-labels / backporting (pull_request_target) Has been skipped
milestone / set (pull_request_target) Has been skipped
testing / backend-checks (pull_request) Successful in 14m46s
testing / test-e2e (2/2) (pull_request) Successful in 4m36s
testing / test-e2e (1/2) (pull_request) Successful in 2m54s
testing / test-unit (pull_request) Successful in 11m39s
testing / test-pgsql (4/4) (pull_request) Successful in 9m37s
testing / test-pgsql (1/4) (pull_request) Successful in 8m48s
1933b82b74
pat-s merged commit 18caeb0f7b into v17.0/forgejo-codefloe 2026-11-07 10:01:27 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!255
No description provided.