If there's a repo with the same name, the migration throws a 500 error #1868

Closed
opened 2025-11-02 04:15:50 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @NefixEstrada on GitHub (Jun 5, 2018).

  • Gitea version (or commit ref): 1.1.0+1336-gd62bc336
  • Git version: 2.15.2-r0
  • Operating system: Alpine Linux 3.7 (Docker)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

docker logs gitea

[Macaron] 2018-06-05 18:26:31: Started GET / for 192.168.5.5
[Macaron] 2018-06-05 18:26:32: Completed GET / 200 OK in 69.328709ms
[Macaron] 2018-06-05 18:26:32: Started GET /api/v1/repos/search?uid=1&q=&limit=15&mode= for 192.168.5.5
[Macaron] 2018-06-05 18:26:32: Completed GET /api/v1/repos/search?uid=1&q=&limit=15&mode= 200 OK in 17.317737ms
[Macaron] 2018-06-05 18:26:34: Started GET /repo/migrate for 192.168.5.5
[Macaron] 2018-06-05 18:26:34: Completed GET /repo/migrate 200 OK in 23.573387ms
[Macaron] 2018-06-05 18:26:43: Started POST /repo/migrate for 192.168.5.5
[Macaron] 2018-06-05 18:26:43: Completed POST /repo/migrate 404 Not Found in 27.013216ms

gitea.logs has no relevant logs

Description

When you try to migrate a repository and there's already a repository with the name you set, it throws a 500 error

Screenshots

captura de 2018-06-05 20-40-46

I'll try to solve it, but I don't think I'll be able do it

Originally created by @NefixEstrada on GitHub (Jun 5, 2018). - Gitea version (or commit ref): 1.1.0+1336-gd62bc336 - Git version: 2.15.2-r0 - Operating system: Alpine Linux 3.7 (Docker) - Database (use `[x]`): - [X] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [X] Not relevant - Log gist: `docker logs gitea` ``` [Macaron] 2018-06-05 18:26:31: Started GET / for 192.168.5.5 [Macaron] 2018-06-05 18:26:32: Completed GET / 200 OK in 69.328709ms [Macaron] 2018-06-05 18:26:32: Started GET /api/v1/repos/search?uid=1&q=&limit=15&mode= for 192.168.5.5 [Macaron] 2018-06-05 18:26:32: Completed GET /api/v1/repos/search?uid=1&q=&limit=15&mode= 200 OK in 17.317737ms [Macaron] 2018-06-05 18:26:34: Started GET /repo/migrate for 192.168.5.5 [Macaron] 2018-06-05 18:26:34: Completed GET /repo/migrate 200 OK in 23.573387ms [Macaron] 2018-06-05 18:26:43: Started POST /repo/migrate for 192.168.5.5 [Macaron] 2018-06-05 18:26:43: Completed POST /repo/migrate 404 Not Found in 27.013216ms ``` `gitea.logs` has no relevant logs ## Description When you try to migrate a repository and there's already a repository with the name you set, it throws a 500 error ## Screenshots ![captura de 2018-06-05 20-40-46](https://user-images.githubusercontent.com/22214853/40995906-c2ad8a3e-6900-11e8-8ec4-ebd9e921310e.png) I'll try to solve it, but I don't think I'll be able do it
GiteaMirror added the type/bug label 2025-11-02 04:15:50 -06:00
Author
Owner

@depado commented on GitHub (Jun 7, 2018):

Confirmed with SQLite database too.

@depado commented on GitHub (Jun 7, 2018): Confirmed with SQLite database too.
Author
Owner

@NefixEstrada commented on GitHub (Jun 7, 2018):

It has a really simple solution though I'm not sure how to implement it. The solution resides in this function.

Things that need to be added:

  • Check if there's already a repository with the name the user is trying to import
  • If it's the case, return a 409 response (with a fancy error)

It's really really trivial, but I have no clue how to do it

@NefixEstrada commented on GitHub (Jun 7, 2018): It has a really simple solution though I'm not sure how to implement it. The solution resides in [this](https://github.com/go-gitea/gitea/blob/master/routers/repo/repo.go#L211) function. Things that need to be added: - Check if there's already a repository with the name the user is trying to import - If it's the case, return a 409 response (with a fancy error) It's really really trivial, but I have no clue how to do it
Author
Owner

@davidak commented on GitHub (Aug 4, 2018):

Maybe just validate the name inside the form with JS client side and mark field red and show warning.

@davidak commented on GitHub (Aug 4, 2018): Maybe just validate the name inside the form with JS client side and mark field red and show warning.
Author
Owner

@NefixEstrada commented on GitHub (Aug 7, 2018):

I think that that would be a bad fix. The API should return a 400 error and then the app should show the error. The JS warning is a nice to have, but it's not enough since you could have the 500 error again @davidak

@NefixEstrada commented on GitHub (Aug 7, 2018): I think that that would be a bad fix. The API should return a 400 error and then the app should show the error. The JS warning is a nice to have, but it's not enough since you could have the 500 error again @davidak
Author
Owner

@davidak commented on GitHub (Aug 7, 2018):

The JS warning is a nice to have, but it's not enough since you could have the 500 error again

it should prevent you from submitting the form.

but you are right, i forgot the API. then it has to be serverside and maybe clientside in addition in JS

@davidak commented on GitHub (Aug 7, 2018): >The JS warning is a nice to have, but it's not enough since you could have the 500 error again it should prevent you from submitting the form. but you are right, i forgot the API. then it has to be serverside and maybe clientside in addition in JS
Author
Owner

@stale[bot] commented on GitHub (Jan 15, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 15, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@davidak commented on GitHub (Jan 15, 2019):

I can still reproduce it.

Tested on https://try.gitea.io/ with version 270fa6d.

@davidak commented on GitHub (Jan 15, 2019): I can still reproduce it. Tested on https://try.gitea.io/ with version 270fa6d.
Author
Owner

@NefixEstrada commented on GitHub (Jan 15, 2019):

I'm going to fix it, since I've already learned Go

@NefixEstrada commented on GitHub (Jan 15, 2019): I'm going to fix it, since I've already learned Go
Author
Owner

@NefixEstrada commented on GitHub (Jan 19, 2019):

So, I've been trying to fix it but I had no luck. I'm not sure which is the method that gets called (does the API have a different method?). Also I don't know how am I supposed to access the user repository list :/

@NefixEstrada commented on GitHub (Jan 19, 2019): So, I've been trying to fix it but I had no luck. I'm not sure which is the method that gets called (does the API have a different method?). Also I don't know how am I supposed to access the user repository list :/
Author
Owner

@lunny commented on GitHub (Feb 26, 2019):

@NefixEstrada I sent a PR #6188, could you confirm that fixed your issue?

@lunny commented on GitHub (Feb 26, 2019): @NefixEstrada I sent a PR #6188, could you confirm that fixed your issue?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1868