go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.6k stars 5.45k forks source link

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

Closed NefixEstrada closed 5 years ago

NefixEstrada commented 6 years ago

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

depado commented 6 years ago

Confirmed with SQLite database too.

NefixEstrada commented 6 years ago

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:

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

davidak commented 6 years ago

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

NefixEstrada commented 6 years ago

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

davidak commented 6 years ago

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

stale[bot] commented 5 years ago

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.

davidak commented 5 years ago

I can still reproduce it.

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

NefixEstrada commented 5 years ago

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

NefixEstrada commented 5 years ago

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 :/

lunny commented 5 years ago

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