Skip to content

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

Closed
@wxiaoguang

Description

@wxiaoguang
Contributor

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

Activity

lunny

lunny commented on Jan 14, 2022

@lunny
Member

Is there any branch in this repository?

ghost

ghost commented on Jan 14, 2022

@ghost

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

zeripath

zeripath commented on Jan 14, 2022

@zeripath
Contributor

this is I presume related to an adopted repository?

wxiaoguang

wxiaoguang commented on Jan 15, 2022

@wxiaoguang
ContributorAuthor

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

ghost

ghost commented on Jan 15, 2022

@ghost

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.

somera

somera commented on Jan 15, 2022

@somera

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

zeripath

zeripath commented on Jan 15, 2022

@zeripath
Contributor

I can't reproduce this on main/1.16.0.

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

modified the milestone: 1.16.0 on Jan 15, 2022
added
issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detail
on Jan 15, 2022
zeripath

zeripath commented on Jan 15, 2022

@zeripath
Contributor

Can anyone reproduce this on 1.16?

wxiaoguang

wxiaoguang commented on Jan 15, 2022

@wxiaoguang
ContributorAuthor

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)

ghost

ghost commented on Jan 15, 2022

@ghost

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

wxiaoguang

wxiaoguang commented on Jan 15, 2022

@wxiaoguang
ContributorAuthor

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.

zeripath

zeripath commented on Jan 15, 2022

@zeripath
Contributor

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.

ghost

ghost commented on Jan 15, 2022

@ghost

pandas-dev/pandas@50ac498

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

added a commit that references this issue on Jan 15, 2022
37136d5
zeripath

zeripath commented on Jan 15, 2022

@zeripath
Contributor

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

changed the title [-]500 error when default banch doesn't exist[/-] [+]500 error when default banch doesn't exist on owner/repo/branches page[/+] on Jan 15, 2022
removed
issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detail
on Jan 15, 2022
added a commit that references this issue on Jan 16, 2022
52bfb7f
added a commit that references this issue on Mar 28, 2022
18f7d93
locked and limited conversation to collaborators on Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @lunny@zeripath@wxiaoguang@somera

      Issue actions

        500 error when default banch doesn't exist on owner/repo/branches page · Issue #18265 · go-gitea/gitea