500 error when when trying to transfer repository from user to organization #7846

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

Originally created by @witten on GitHub (Sep 14, 2021).

  • Gitea version (or commit ref): 1.15.2
  • Git version: 2.30.2 (as part of Gitea container)
  • Operating system: Debian 11 running official Gitea Docker container (based on Alpine 3.13.6), run via Docker Compose
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Browser: Firefox 91.0.2 (ad blockers disabled)
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No (tried moving a test repository to a pre-existing test organization)
  • Log gist: https://gist.github.com/witten/5ee4772a7031ea5d6ce6e45ffa61e9ce

Description

When trying to transfer a repository from my user to an organization I own, I receive a 500 from Gitea and the transfer doesn't go through.

Potentially relevant: https://github.com/go-gitea/gitea/issues/10230

Screenshots

bug1

bug2

HTTP request payload

_csrf=REDACTED&action=transfer&repo_name=borgmatic&new_owner_name=borgmatic-collective
Originally created by @witten on GitHub (Sep 14, 2021). - Gitea version (or commit ref): 1.15.2 - Git version: 2.30.2 (as part of Gitea container) - Operating system: Debian 11 running official Gitea Docker container (based on Alpine 3.13.6), run via Docker Compose - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Browser: Firefox 91.0.2 (ad blockers disabled) - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No (tried moving a test repository to a pre-existing test organization) - Log gist: https://gist.github.com/witten/5ee4772a7031ea5d6ce6e45ffa61e9ce ## Description When trying to transfer a repository from my user to an organization I own, I receive a 500 from Gitea and the transfer doesn't go through. Potentially relevant: https://github.com/go-gitea/gitea/issues/10230 ## Screenshots ![bug1](https://user-images.githubusercontent.com/17146/133303068-d5481478-8543-404e-a068-278f7dc7b02a.png) ![bug2](https://user-images.githubusercontent.com/17146/133303078-4ed80b89-64de-4117-b5e5-a0369f74780a.png) ## HTTP request payload ``` _csrf=REDACTED&action=transfer&repo_name=borgmatic&new_owner_name=borgmatic-collective ```
Author
Owner

@zeripath commented on GitHub (Sep 14, 2021):

Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems

We need the logs for the 500

@zeripath commented on GitHub (Sep 14, 2021): Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems We need the logs for the 500
Author
Owner

@witten commented on GitHub (Sep 14, 2021):

I've just updated the linked gist as per your debugging instructions. It looks like the error in question is this:

2021/09/14 17:38:43 .../web/repo/setting.go:593:SettingsPost() [E] TransferOwnership: getCollaborators: user does not exist [uid: 38, name: , keyid: 0]
@witten commented on GitHub (Sep 14, 2021): I've just updated the [linked gist](https://gist.github.com/witten/5ee4772a7031ea5d6ce6e45ffa61e9ce) as per your debugging instructions. It looks like the error in question is this: ``` 2021/09/14 17:38:43 .../web/repo/setting.go:593:SettingsPost() [E] TransferOwnership: getCollaborators: user does not exist [uid: 38, name: , keyid: 0] ```
Author
Owner

@zeripath commented on GitHub (Sep 14, 2021):

OK so the error report is coming from:

659b946eda/routers/web/repo/setting.go (L593)

but the error is actually created:

659b946eda/models/repo_transfer.go (L266)

and will actually come from:

659b946eda/models/repo_collaboration.go (L88-L91)

Now the interesting part here is that this implies that there is a user (user id: 38) who is listed as a collaborator of that repo who is no longer in existence.

This is a db consistency issue but I think we should just handle this by ignoring this user.

@zeripath commented on GitHub (Sep 14, 2021): OK so the error report is coming from: https://github.com/go-gitea/gitea/blob/659b946edaff08d38067a13b9d3157b12b1131d2/routers/web/repo/setting.go#L593 but the error is actually created: https://github.com/go-gitea/gitea/blob/659b946edaff08d38067a13b9d3157b12b1131d2/models/repo_transfer.go#L266 and will actually come from: https://github.com/go-gitea/gitea/blob/659b946edaff08d38067a13b9d3157b12b1131d2/models/repo_collaboration.go#L88-L91 Now the interesting part here is that this implies that there is a user (user id: 38) who is listed as a collaborator of that repo who is no longer in existence. This is a db consistency issue but I think we should just handle this by ignoring this user.
Author
Owner

@witten commented on GitHub (Sep 14, 2021):

Interesting! I deleted a bunch of a spammers a while back, and it's possible that impacted a collaborator on the repo in question. So maybe this is a non-issue for other Gitea instances?

@witten commented on GitHub (Sep 14, 2021): Interesting! I deleted a bunch of a spammers a while back, and it's possible that impacted a collaborator on the repo in question. So maybe this is a non-issue for other Gitea instances?
Author
Owner

@zeripath commented on GitHub (Sep 14, 2021):

Well it's kinda bad that this kills things - we should simply tolerate and not die.

I also don't think that our doctor will fix this inconsistency either so that needs fixing too.

@zeripath commented on GitHub (Sep 14, 2021): Well it's kinda bad that this kills things - we should simply tolerate and not die. I also don't think that our doctor will fix this inconsistency either so that needs fixing too.
Author
Owner

@zeripath commented on GitHub (Sep 14, 2021):

I think you could probably just manually remove the collaborator with that userid from the table directly and the problem will go away for you however we need to fix this so leave this bug open and PR will close it.

@zeripath commented on GitHub (Sep 14, 2021): I think you could probably just manually remove the collaborator with that userid from the table directly and the problem will go away for you however we need to fix this so leave this bug open and PR will close it.
Author
Owner

@witten commented on GitHub (Sep 14, 2021):

Got it! I confirmed that deleting the dangling collaborator from the collaboration table fixed the problem, and I'm now able to transfer the repository successfully. I'll leave this ticket open for the PR.

Thanks for your help!

@witten commented on GitHub (Sep 14, 2021): Got it! I confirmed that deleting the dangling collaborator from the `collaboration` table fixed the problem, and I'm now able to transfer the repository successfully. I'll leave this ticket open for the PR. Thanks for your help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7846