Failed migration leaves database in a bad state #3378

Closed
opened 2025-11-02 05:10:43 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @rfwatson on GitHub (May 25, 2019).

  • Gitea version (or commit ref): df255783
  • Git version: 2.17.1
  • Operating system: Linux x86_64
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
  • Log gist:

Description

Failed migration does not rollback database properly.

To recreate:

  1. Visit https://try.gitea.io/repo/migrate
  2. Enter clone URL https://github.com/nope/nope.git and repo name nope
  3. Leave clone authentication blank
  4. Submit form

**Expected behaviour: **

See error message Authentication failed: Clone: exit status 128 - fatal: could not read Username for 'https://github.com': No such device or address and no repo is created in the database

Actual behaviour

Error message above is displayed but an empty repo is also created in the database, shows on the user's profile and generates a 500 when visited.

Note that deleting the repo from the DB is not enough to clean this up, there are also entries in the action table too (and possibly elsewhere)

Screenshots

N/A

Originally created by @rfwatson on GitHub (May 25, 2019). - Gitea version (or commit ref): `df255783` - Git version: 2.17.1 - Operating system: Linux x86_64 - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) - https://try.gitea.io/rob2/nope - [ ] No - [ ] Not relevant - Log gist: ## Description Failed migration does not rollback database properly. **To recreate:** 1. Visit https://try.gitea.io/repo/migrate 2. Enter clone URL `https://github.com/nope/nope.git` and repo name `nope` 3. Leave clone authentication blank 4. Submit form **Expected behaviour: ** See error message _Authentication failed: Clone: exit status 128 - fatal: could not read Username for 'https://github.com': No such device or address_ and no repo is created in the database **Actual behaviour** Error message above is displayed but an empty repo is also created in the database, shows on the user's profile and generates a 500 when visited. Note that deleting the repo from the DB is not enough to clean this up, there are also entries in the `action` table too (and possibly elsewhere) ## Screenshots N/A
Author
Owner

@rfwatson commented on GitHub (May 25, 2019):

This occurs because when the rollback should be attempted here, g.repo is nil.

@rfwatson commented on GitHub (May 25, 2019): This occurs because when the rollback should be attempted [here](https://github.com/rfwatson/gitea/blob/df2557835b2235b48d1ed979abb1a1d42607e96a/modules/migrations/gitea.go#L397), `g.repo` is `nil`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3378