Importing a local repo using the API doesn't seem to work properly. #4389

Closed
opened 2025-11-02 05:49:03 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @guillep2k on GitHub (Nov 25, 2019).

Gitea: 1.10.0 (release)

Importing a local repository from the API seems to miss certain steps. When I do:

curl -X POST https://git.xxx.com.ar/api/v1/repos/migrate -H 'accept: application/json' \
    -H 'Authorization: token xxxxxxxx' -H 'Content-Type: application/json' \
    -d '{ "clone_addr": "/home/xxxxx/convert/projectxxxx", "description": "Project XXX",
          "mirror": false, "private": true, "repo_name": "projectxxx", "uid": 9}' -i

The call succeeds and I get the expected JSON response (new repo ID: 103), but when I use the UI to see the repository I get a 500 Server Error. The log shows:

2019/11/25 11:21:23 routers/repo/view.go:376:Home() [E] models.GetMigratingTask: task is not exist [id: 0, repo_id: 103, type: 0]

The record in the database was created and the directory for the repo was created too (sorry, I couldn't check any further because this was my prod site and I was in a hurry). The row in the database was:

gitea=# select * from repository where id = 103;
 id  | owner_id |   lower_name   |      name      |   description    | website | default_branch | num_watches | num_stars | num_forks | num_issues | num_closed_issues | num_pulls | num_closed_pulls | num_milestones | num_closed_milestones | is_private | is_empty | is_archived | is_mirror | is_fork | fork_id |  size   | is_fsck_enabled | close_issues_via_commit_in_any_branch | topics | created_unix | updated_unix | avatar | original_url | status | original_service_type
-----+----------+----------------+----------------+------------------+---------+----------------+-------------+-----------+-----------+------------+-------------------+-----------+------------------+----------------+-----------------------+------------+----------+-------------+-----------+---------+---------+---------+-----------------+---------------------------------------+--------+--------------+--------------+--------+--------------+--------+-----------------------
 103 |        9 | xxxxxxxxxxxxxx | xxxxxxxxxxxxxx | XXXXXXXXXXXXXXXX |         | master         |           1 |         0 |         0 |          0 |                 0 |         0 |                0 |              0 |                     0 | t          | f        | f           | f         | f       | 0       | 4741120 | t               | f                                     | null   |   1574691626 |   1574691627 |        |              |      1 |            0
(1 row)
Originally created by @guillep2k on GitHub (Nov 25, 2019). Gitea: 1.10.0 (release) Importing a local repository from the API seems to miss certain steps. When I do: ``` curl -X POST https://git.xxx.com.ar/api/v1/repos/migrate -H 'accept: application/json' \ -H 'Authorization: token xxxxxxxx' -H 'Content-Type: application/json' \ -d '{ "clone_addr": "/home/xxxxx/convert/projectxxxx", "description": "Project XXX", "mirror": false, "private": true, "repo_name": "projectxxx", "uid": 9}' -i ``` The call succeeds and I get the expected JSON response (new repo ID: 103), but when I use the UI to see the repository I get a 500 Server Error. The log shows: ``` 2019/11/25 11:21:23 routers/repo/view.go:376:Home() [E] models.GetMigratingTask: task is not exist [id: 0, repo_id: 103, type: 0] ``` The record in the database was created and the _directory_ for the repo was created too (sorry, I couldn't check any further because this was my prod site and I was in a hurry). The row in the database was: ``` gitea=# select * from repository where id = 103; id | owner_id | lower_name | name | description | website | default_branch | num_watches | num_stars | num_forks | num_issues | num_closed_issues | num_pulls | num_closed_pulls | num_milestones | num_closed_milestones | is_private | is_empty | is_archived | is_mirror | is_fork | fork_id | size | is_fsck_enabled | close_issues_via_commit_in_any_branch | topics | created_unix | updated_unix | avatar | original_url | status | original_service_type -----+----------+----------------+----------------+------------------+---------+----------------+-------------+-----------+-----------+------------+-------------------+-----------+------------------+----------------+-----------------------+------------+----------+-------------+-----------+---------+---------+---------+-----------------+---------------------------------------+--------+--------------+--------------+--------+--------------+--------+----------------------- 103 | 9 | xxxxxxxxxxxxxx | xxxxxxxxxxxxxx | XXXXXXXXXXXXXXXX | | master | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | t | f | f | f | f | 0 | 4741120 | t | f | null | 1574691626 | 1574691627 | | | 1 | 0 (1 row) ```
GiteaMirror added the type/bug label 2025-11-02 05:49:03 -06:00
Author
Owner

@mrtwnklr commented on GitHub (Dec 5, 2019):

I am using gitea 1.10 linux-amd64 and am facing the same problem after migrating private and public github repositories with this script: https://jpmens.net/2019/04/15/i-mirror-my-github-repositories-to-gitea/ . This script is using the rest api. The problem seems to exist for every of these repositories (I have only verified some of these).
The problem is not reproducible with 1.9.6.

Console output when triggering the migration (for one of the repositories):

[Macaron] 2019-12-05 18:29:59: Completed POST /api/v1/repos/migrate 201 Created in 5.224582117s
[Macaron] 2019-12-05 18:29:59: Started POST /api/v1/repos/migrate for 127.0.0.1

Afterwards the directory ~/git-repositories contains the cloned git repository. An issued git rev-list --all --objects | sha1sum command on both the original repository and the gitea mirrored repository does return the same value.

Console output when opening the according gitea repository page in browser:

[Macaron] 2019-12-05 19:22:22: Started GET /mrtwnklr/mrtwnklr-ansible-playbook-warship-proof-of-concept-environment for 127.0.0.1
[Macaron] 2019-12-05 19:22:22: Completed GET /mrtwnklr/mrtwnklr-ansible-playbook-warship-proof-of-concept-environment 500 Internal Server Error in 29.240684ms

Log output when opening gitea repository page in browser:

2019/12/05 18:19:51 routers/repo/view.go:376:Home() [E] models.GetMigratingTask: task is not exist [id: 0, repo_id: 62, type: 0]
@mrtwnklr commented on GitHub (Dec 5, 2019): I am using gitea 1.10 linux-amd64 and am facing the same problem after migrating private and public github repositories with this script: https://jpmens.net/2019/04/15/i-mirror-my-github-repositories-to-gitea/ . This script is using the rest api. The problem seems to exist for every of these repositories (I have only verified some of these). The problem is **not reproducible with 1.9.6**. Console output when triggering the migration (for one of the repositories): ``` [Macaron] 2019-12-05 18:29:59: Completed POST /api/v1/repos/migrate 201 Created in 5.224582117s [Macaron] 2019-12-05 18:29:59: Started POST /api/v1/repos/migrate for 127.0.0.1 ``` Afterwards the directory `~/git-repositories` contains the cloned git repository. An issued `git rev-list --all --objects | sha1sum` command on both the original repository and the gitea mirrored repository does return the same value. Console output when opening the according gitea repository page in browser: ``` [Macaron] 2019-12-05 19:22:22: Started GET /mrtwnklr/mrtwnklr-ansible-playbook-warship-proof-of-concept-environment for 127.0.0.1 [Macaron] 2019-12-05 19:22:22: Completed GET /mrtwnklr/mrtwnklr-ansible-playbook-warship-proof-of-concept-environment 500 Internal Server Error in 29.240684ms ``` Log output when opening gitea repository page in browser: ``` 2019/12/05 18:19:51 routers/repo/view.go:376:Home() [E] models.GetMigratingTask: task is not exist [id: 0, repo_id: 62, type: 0] ```
Author
Owner

@lunny commented on GitHub (Dec 6, 2019):

@mrtwnklr have you used v1.10.0?

@lunny commented on GitHub (Dec 6, 2019): @mrtwnklr have you used v1.10.0?
Author
Owner

@mrtwnklr commented on GitHub (Dec 6, 2019):

@lunny I reproduced it with 1.10 and 1.10.0

@mrtwnklr commented on GitHub (Dec 6, 2019): @lunny I reproduced it with [1.10](https://dl.gitea.io/gitea/1.10/gitea-1.10-linux-amd64) and [1.10.0](https://dl.gitea.io/gitea/1.10.0/gitea-1.10.0-linux-amd64)
Author
Owner

@neingeist commented on GitHub (Dec 8, 2019):

I have the same issue with 1.10.1 (current Docker image version for 1.10). I tried to import local repositories using the API, the repos are there I just get a 500 error and the GetMigratingTask: task is not exist error in the log.

@neingeist commented on GitHub (Dec 8, 2019): I have the same issue with 1.10.1 (current Docker image version for 1.10). I tried to import local repositories using the API, the repos are there I just get a 500 error and the `GetMigratingTask: task is not exist` error in the log.
Author
Owner

@AlexKMDev commented on GitHub (Dec 27, 2019):

I found a small workaround.

  1. Check that there are no running migration tasks
gitea=# select * from task;
 id | doer_id | owner_id | repo_id | type | status | start_time | end_time | payload_content | errors | created
----+---------+----------+---------+------+--------+------------+----------+-----------------+--------+---------
(0 rows)
  1. Update repository statuses manually from RepositoryBeingMigrated to RepositoryReady
gitea=# update repository set status = 0 where status = 1;
UPDATE 1

It seems the api method doesn't run this code 1615b3c187/models/task.go (L222-L240) for some reason when importing local repositories.

@AlexKMDev commented on GitHub (Dec 27, 2019): I found a small workaround. 1. Check that there are no running migration tasks ``` gitea=# select * from task; id | doer_id | owner_id | repo_id | type | status | start_time | end_time | payload_content | errors | created ----+---------+----------+---------+------+--------+------------+----------+-----------------+--------+--------- (0 rows) ``` 2. Update repository statuses manually from `RepositoryBeingMigrated` to `RepositoryReady` ``` gitea=# update repository set status = 0 where status = 1; UPDATE 1 ``` It seems the api method doesn't run this code https://github.com/go-gitea/gitea/blob/1615b3c1874932c08d504fcc111f46105a2207b6/models/task.go#L222-L240 for some reason when importing local repositories.
Author
Owner

@neingeist commented on GitHub (Dec 27, 2019):

Another workaround if you're setting up a new Gitea installation: I used 1.9 to import and then upgraded to 1.10.

@neingeist commented on GitHub (Dec 27, 2019): Another workaround if you're setting up a new Gitea installation: I used 1.9 to import and then upgraded to 1.10.
Author
Owner

@lafriks commented on GitHub (Dec 27, 2019):

Fixed in #9511

@lafriks commented on GitHub (Dec 27, 2019): Fixed in #9511
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4389