Gitea: If there's a repo with the same name, the migration throws a 500 error

Created on 5 Jun 2018  路  10Comments  路  Source: go-gitea/gitea

  • 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

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

kinbug

All 10 comments

Confirmed with SQLite database too.

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

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

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

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

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.

I can still reproduce it.

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

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

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 I sent a PR #6188, could you confirm that fixed your issue?

Was this page helpful?
0 / 5 - 0 ratings