Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wxiaoguang opened this issue Jan 14, 2022 · 14 comments · Fixed by #18290
Closed

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

wxiaoguang opened this issue Jan 14, 2022 · 14 comments · Fixed by #18290
Labels

Comments

@wxiaoguang
Copy link
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
@lunny
Copy link
Member

lunny commented Jan 14, 2022

Is there any branch in this repository?

@ghost
Copy link

ghost commented Jan 14, 2022

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

@zeripath
Copy link
Contributor

this is I presume related to an adopted repository?

@wxiaoguang
Copy link
Contributor Author

@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
Copy link

ghost commented 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.

@somera
Copy link

somera commented 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

@zeripath
Copy link
Contributor

zeripath commented 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 zeripath modified the milestone: 1.16.0 Jan 15, 2022
@zeripath zeripath added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Jan 15, 2022
@zeripath
Copy link
Contributor

Can anyone reproduce this on 1.16?

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented 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)

@ghost
Copy link

ghost commented Jan 15, 2022

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

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented 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.

@zeripath
Copy link
Contributor

zeripath commented 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.

@ghost
Copy link

ghost commented Jan 15, 2022

pandas-dev/pandas@50ac498

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

zeripath added a commit to zeripath/gitea that referenced this issue Jan 15, 2022
This PR more nicely handles a missing default branch in owner/repo/branches

Fix go-gitea#18265

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor

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

@zeripath zeripath changed the title 500 error when default banch doesn't exist 500 error when default banch doesn't exist on owner/repo/branches page Jan 15, 2022
@zeripath zeripath removed the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Jan 15, 2022
wxiaoguang pushed a commit that referenced this issue Jan 16, 2022
)

This PR more nicely handles a missing default branch in owner/repo/branches

Fix #18265

Signed-off-by: Andrew Thornton <art27@cantab.net>
Chianina pushed a commit to Chianina/gitea that referenced this issue Mar 28, 2022
…gitea#18290)

This PR more nicely handles a missing default branch in owner/repo/branches

Fix go-gitea#18265

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants