500 error when default banch doesn't exist on owner/repo/branches page #8351

Closed
opened 2025-11-02 08:03:21 -06:00 by GiteaMirror · 14 comments
Owner

Originally created by @wxiaoguang on GitHub (Jan 14, 2022).

Gitea version: 1.15.9

Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 Started GET /testuser/pandas/branches for 127.0.0.1:48032
Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 ...s/web/repo/branch.go:168:loadBranches() [E] loadBranches: get default branch: branch does not exist [name: master]
Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 ...s/web/repo/branch.go:169:loadBranches() [E] GetDefaultBranch: branch does not exist [name: master]
Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 Completed GET /testuser/pandas/branches 500 Internal Server Error in 110.488967ms
Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 Started GET /assets/img/500.png for 127.0.0.1:48034
Originally created by @wxiaoguang on GitHub (Jan 14, 2022). Gitea version: 1.15.9 ``` Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 Started GET /testuser/pandas/branches for 127.0.0.1:48032 Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 ...s/web/repo/branch.go:168:loadBranches() [E] loadBranches: get default branch: branch does not exist [name: master] Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 ...s/web/repo/branch.go:169:loadBranches() [E] GetDefaultBranch: branch does not exist [name: master] Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 Completed GET /testuser/pandas/branches 500 Internal Server Error in 110.488967ms Jan 13 05:25:12 my-host gitea[10979]: 2022/01/13 05:25:12 Started GET /assets/img/500.png for 127.0.0.1:48034 ```
GiteaMirror added the type/bug label 2025-11-02 08:03:21 -06:00
Author
Owner

@lunny commented on GitHub (Jan 14, 2022):

Is there any branch in this repository?

@lunny commented on GitHub (Jan 14, 2022): Is there any branch in this repository?
Author
Owner

@ghost commented on GitHub (Jan 14, 2022):

Yes, but the original repository does not contain a 'master' branch ( e.g., https://github.com/pandas-dev/pandas )

@ghost commented on GitHub (Jan 14, 2022): > Yes, but the original repository does not contain a 'master' branch ( e.g., https://github.com/pandas-dev/pandas )
Author
Owner

@zeripath commented on GitHub (Jan 14, 2022):

this is I presume related to an adopted repository?

@zeripath commented on GitHub (Jan 14, 2022): this is I presume related to an adopted repository?
Author
Owner

@wxiaoguang commented on GitHub (Jan 15, 2022):

@tim-kong Can you help to confirm the problem? How the /testuser/pandas comes, was it adopted (imported from Gitea repository directory directly) before?

@wxiaoguang commented on GitHub (Jan 15, 2022): @tim-kong Can you help to confirm the problem? How the `/testuser/pandas` comes, was it adopted (imported from Gitea repository directory directly) before?
Author
Owner

@ghost commented on GitHub (Jan 15, 2022):

OK. Login as testuser , and just mirror the Pandas repository ('https://github.com/pandas-dev/pandas') using Gitea web page (http://example.com/repo/migrate). Don't need to do anything. And when accessing http://example.com/testuser/pandas/branches you well see 500 error.

Thanks.

@ghost commented on GitHub (Jan 15, 2022): > OK. Login as _testuser_ , and just mirror the Pandas repository ('https://github.com/pandas-dev/pandas') using Gitea web page (http://example.com/repo/migrate). Don't need to do anything. And when accessing http://example.com/testuser/pandas/branches you well see 500 error. Thanks.
Author
Owner

@somera commented on GitHub (Jan 15, 2022):

OK. Login as testuser , and just mirror the Pandas repository ('https://github.com/pandas-dev/pandas') using Gitea web page (http://example.com/repo/migrate). Don't need to do anything. And when accessing http://example.com/testuser/pandas/branches you well see 500 error.

Thanks.

Works for me in Gitea 1.15.10. It need some seconds, but it works.

My URL: http://nuc-mini-celeron:3000/pandas-dev/pandas/branches

Powered by Gitea Version: 1.15.10 Seite: 4904ms Template: 26ms

image

@somera commented on GitHub (Jan 15, 2022): > > > > OK. Login as _testuser_ , and just mirror the Pandas repository ('https://github.com/pandas-dev/pandas') using Gitea web page (http://example.com/repo/migrate). Don't need to do anything. And when accessing http://example.com/testuser/pandas/branches you well see 500 error. > > Thanks. Works for me in Gitea 1.15.10. It need some seconds, but it works. My URL: http://nuc-mini-celeron:3000/pandas-dev/pandas/branches `Powered by Gitea Version: 1.15.10 Seite: 4904ms Template: 26ms` ![image](https://user-images.githubusercontent.com/8334250/149620061-2319c521-f453-45bc-ae6c-0265e563ac69.png)
Author
Owner

@zeripath commented on GitHub (Jan 15, 2022):

I can't reproduce this on main/1.16.0.

(I had this right I can't reproduce this on main)

@zeripath commented on GitHub (Jan 15, 2022): I can't reproduce this on main/1.16.0. (I had this right I can't reproduce this on main)
Author
Owner

@zeripath commented on GitHub (Jan 15, 2022):

Can anyone reproduce this on 1.16?

@zeripath commented on GitHub (Jan 15, 2022): Can anyone reproduce this on 1.16?
Author
Owner

@wxiaoguang commented on GitHub (Jan 15, 2022):

I can trigger the bug manually in 1.16:

  1. Prepare a normal git repository
  2. Go to database, change the repository.default_branch to a non-existing one
  3. Visit /owner/repo/branches
  4. Then we get the 500 error

I can imagine a real case: if a user changes a git repository with a different default branch name (eg: changes the git repository on the server), they would also trigger this bug. I am not sure whether force-push would also trigger such bug.

Maybe the better behavior is getting rid of the 500 page (internal error should be something serious, but not this case)

@wxiaoguang commented on GitHub (Jan 15, 2022): I can trigger the bug manually in 1.16: 1. Prepare a normal git repository 2. Go to database, change the `repository`.`default_branch` to a non-existing one 3. Visit `/owner/repo/branches` 4. Then we get the 500 error I can imagine a real case: if a user changes a git repository with a different default branch name (eg: changes the git repository on the server), they would also trigger this bug. I am not sure whether force-push would also trigger such bug. Maybe the better behavior is getting rid of the 500 page (internal error should be something serious, but not this case)
Author
Owner

@ghost commented on GitHub (Jan 15, 2022):

I update my gitea version to 1.15.10, and cannot trigger the bug.

@ghost commented on GitHub (Jan 15, 2022): I update my gitea version to 1.15.10, and cannot trigger the bug.
Author
Owner

@wxiaoguang commented on GitHub (Jan 15, 2022):

I update my gitea version to 1.15.10, and cannot trigger the bug.

Actually, 1.15.10 only contains some small fixes, and should not be related to this bug (https://github.com/go-gitea/gitea/releases/tag/v1.15.10) . I suspect you did something or Gitea did something, then the default_branch gets a correct value.

@wxiaoguang commented on GitHub (Jan 15, 2022): > I update my gitea version to 1.15.10, and cannot trigger the bug. Actually, 1.15.10 only contains some small fixes, and should not be related to this bug (https://github.com/go-gitea/gitea/releases/tag/v1.15.10) . I suspect you did something or Gitea did something, then the `default_branch` gets a correct value.
Author
Owner

@zeripath commented on GitHub (Jan 15, 2022):

I can trigger the bug manually in 1.16:

  1. Prepare a normal git repository
  2. Go to database, change the repository.default_branch to a non-existing one
  3. Visit /owner/repo/branches
  4. Then we get the 500 error

I can imagine a real case: if a user changes a git repository with a different default branch name (eg: changes the git repository on the server), they would also trigger this bug. I am not sure whether force-push would also trigger such bug.

Maybe the better behavior is getting rid of the 500 page (internal error should be something serious, but not this case)

Weirdly I wasn't able to do this on pandas.


AHA The /owner/repo/branches bit was the thing I was missing.

@zeripath commented on GitHub (Jan 15, 2022): > I can trigger the bug manually in 1.16: > > 1. Prepare a normal git repository > 2. Go to database, change the `repository`.`default_branch` to a non-existing one > 3. Visit `/owner/repo/branches` > 4. Then we get the 500 error > > I can imagine a real case: if a user changes a git repository with a different default branch name (eg: changes the git repository on the server), they would also trigger this bug. I am not sure whether force-push would also trigger such bug. > > Maybe the better behavior is getting rid of the 500 page (internal error should be something serious, but not this case) Weirdly I wasn't able to do this on pandas. --- AHA The /owner/repo/branches bit was the thing I was missing.
Author
Owner

@ghost commented on GitHub (Jan 15, 2022):

50ac4981e0

It is probably the root cause.... Pandas has recently replace 'master' with 'main', just several days ago.

@ghost commented on GitHub (Jan 15, 2022): https://github.com/pandas-dev/pandas/commit/50ac4981e0b2dca5fc0c353ddcf3b900925bce9b It is probably the root cause.... Pandas has recently replace 'master' with 'main', just several days ago.
Author
Owner

@zeripath commented on GitHub (Jan 15, 2022):

I've put a PR in to handle this but we might not necessarily backport it.

@zeripath commented on GitHub (Jan 15, 2022): I've put a PR in to handle this but we might not necessarily backport it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8351