FindRecentlyPushedNewBranches finding non-existing Branches #13196

Open
opened 2025-11-02 10:34:33 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @theAkito on GitHub (Jun 24, 2024).

Description

Follow up on #31163. This issue has been worked around in the mentioned issue and this issue is for solving the root problem.

The issue starts to appear, when you upgrade from a pre-1.22 version to the 1.22 version.

The problem displayed itself as the user trying to open a repository and then hitting a HTTP 500 Error, because the system tries to find the default branch named main. Right now, this error is not displayed in the Nightly version of 1.22, because it is just hidden and ignored. The root issue remains unsolved.

I use this space to clarify and further detail the description of the root problem.

This comment by a maintainer suggests, that when a default branch by the default name is missing, the branch might've been deleted, renamed or a default branch might simply not be set, which happened between the upgrade from an older version to 1.22, before the workaround was released.

I can 100% confirm, that this is not the case. My repositories worked for all previous versions, then I switched to 1.22 and suddenly the system looks for a branch, that never existed in any of the repositories on my instance in the first place. No default branches have been ever re-assigned or even deleted.

The root problem is related to the system trying to find the default branch main, even though, there is no reason for looking for it. Even, if it has never been there. It still looks for it. This is one question, that needs to be answered, to be able to properly fix the issue.

I welcome other affected users to comment on this issue and add further information for clarifying the issue at hand.

Gitea Version

1.22-nightly

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Kubernetes via Helm

(Happens on any type of deployment, though.)

Database

PostgreSQL

Originally created by @theAkito on GitHub (Jun 24, 2024). ### Description [Follow up](https://github.com/go-gitea/gitea/issues/31163#issuecomment-2185600813) on #31163. This issue has been worked around in the mentioned issue and this issue is for solving the root problem. The issue starts to appear, when you upgrade from a pre-`1.22` version to the `1.22` version. The problem displayed itself as the user trying to open a repository and then hitting a HTTP 500 Error, because the system tries to find the default branch named `main`. Right now, this error is not displayed in the Nightly version of `1.22`, because it is just hidden and ignored. The root issue remains unsolved. I use this space to clarify and further detail the description of the root problem. This [comment](https://github.com/go-gitea/gitea/issues/31163#issuecomment-2138581805) by a maintainer suggests, that when a default branch by the default name is missing, the branch might've been deleted, renamed or a default branch might simply not be set, which happened between the upgrade from an older version to `1.22`, before the workaround was released. I can 100% confirm, that this is not the case. My repositories worked for all previous versions, then I switched to `1.22` and suddenly the system looks for a branch, that never existed in any of the repositories on my instance in the first place. No default branches have been ever re-assigned or even deleted. The root problem is related to the system trying to find the default branch `main`, even though, there is no reason for looking for it. Even, if it has never been there. It still looks for it. This is one question, that needs to be answered, to be able to properly fix the issue. I welcome other affected users to comment on this issue and add further information for clarifying the issue at hand. ### Gitea Version 1.22-nightly ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Kubernetes via Helm (Happens on any type of deployment, though.) ### Database PostgreSQL
GiteaMirror added the type/bug label 2025-11-02 10:34:33 -06:00
Author
Owner

@CHN-STUDENT commented on GitHub (Jun 24, 2024):

I get same issue when i update 1.21.4 to 1.22.0 Release not nightly,when i push some project code to my gitea origin, i get FindRecentlyPushedNewBranches Error, i do not know how to fix it or downgrad gitea my gitea origin now seems work wrong.

image
image

@wxiaoguang @lunny please help me thanks!

@CHN-STUDENT commented on GitHub (Jun 24, 2024): I get same issue when i update `1.21.4 ` to `1.22.0` Release not nightly,when i push some project code to my gitea origin, i get `FindRecentlyPushedNewBranches` Error, i do not know how to fix it or downgrad gitea my gitea origin now seems work wrong. ![image](https://github.com/go-gitea/gitea/assets/21209416/b0b4e9ed-27a8-46ea-9cc8-fd981284a131) ![image](https://github.com/go-gitea/gitea/assets/21209416/c7c78ea0-9202-4b29-8c60-689eee207ffa) @wxiaoguang @lunny please help me thanks!
Author
Owner

@theAkito commented on GitHub (Jun 24, 2024):

I get same issue when i update 1.21.4 to 1.22.0 Release not nightly,when i push some project code to my gitea origin, i get FindRecentlyPushedNewBranches Error, i do not know how to fix it or downgrad gitea my gitea origin now seems work wrong.

image image

@wxiaoguang @lunny please help me thanks!

Thanks for the information.

Did you check out how to apply the workaround, to make this error disappear? It works for me.

https://github.com/go-gitea/gitea/issues/31163#issuecomment-2180559370

If you have specific questions regarding the setup, perhaps you could ask on the forum for clarification. I would be happy to help.

@theAkito commented on GitHub (Jun 24, 2024): > I get same issue when i update `1.21.4 ` to `1.22.0` Release not nightly,when i push some project code to my gitea origin, i get `FindRecentlyPushedNewBranches` Error, i do not know how to fix it or downgrad gitea my gitea origin now seems work wrong. > > ![image](https://private-user-images.githubusercontent.com/21209416/342269693-b0b4e9ed-27a8-46ea-9cc8-fd981284a131.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyMTk2NDAsIm5iZiI6MTcxOTIxOTM0MCwicGF0aCI6Ii8yMTIwOTQxNi8zNDIyNjk2OTMtYjBiNGU5ZWQtMjdhOC00NmVhLTljYzgtZmQ5ODEyODRhMTMxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI0VDA4NTU0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA4ZmNmYWJkZjQ3ZWE5MzkwZGQ1YzNiYTk4ODE3N2YzM2Y1NWFkNjA0Y2FkN2E1ZWM4NzFiOTc2NmM1MDJhMTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.21PYMNwKh64Jq7_GgCtHxc6_r7VqRowC3WAHZNAakfg) ![image](https://private-user-images.githubusercontent.com/21209416/342270056-c7c78ea0-9202-4b29-8c60-689eee207ffa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyMTk2NDAsIm5iZiI6MTcxOTIxOTM0MCwicGF0aCI6Ii8yMTIwOTQxNi8zNDIyNzAwNTYtYzdjNzhlYTAtOTIwMi00YjI5LThjNjAtNjg5ZWVlMjA3ZmZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI0VDA4NTU0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYzZjcwN2IyOTEyNmQwNjc2NGNiNTM5ZTQyZTRkZmI5MDI5N2FlOTBiYjNhOTBjNTg5NDZhMDBmYzNlYmZjNGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.9NKsUfyjW7JsvqlJr0dBVfsbesvKF6XvcwyOtEOvSaw) > > @wxiaoguang @lunny please help me thanks! Thanks for the information. Did you check out how to apply the workaround, to make this error disappear? It works for me. https://github.com/go-gitea/gitea/issues/31163#issuecomment-2180559370 If you have specific questions regarding the setup, perhaps you could ask on the [forum](https://forum.gitea.com/) for clarification. I would be happy to help.
Author
Owner

@CHN-STUDENT commented on GitHub (Jun 24, 2024):

oh i need to upgrade 1.22-nightly to try?

UPDATE: Yeah, i download then upgrade, now seems it's work correctlly. Thanks! i hope they fixed it by lastest version as soon as quicky and tell every person who meet this issue.

Thanks for your help.

@CHN-STUDENT commented on GitHub (Jun 24, 2024): oh i need to upgrade 1.22-nightly to try? **UPDATE:** Yeah, i download then upgrade, now seems it's work correctlly. Thanks! i hope they fixed it by lastest version as soon as quicky and tell every person who meet this issue. Thanks for your help.
Author
Owner

@wxiaoguang commented on GitHub (Jun 24, 2024):

This comment by a maintainer suggests, that when a default branch by the default name is missing

That's only one case for the "branch sync" problem .....

I can 100% confirm, that this is not the case. My repositories worked for all previous versions, then I switched to 1.22 and suddenly the system looks for a branch, that never existed in any of the repositories on my instance in the first place. No default branches have been ever re-assigned or even deleted.

That's another case: some branches are out-of-sync for some known or unknown reasons, so "sync branches" on the admin dashboard panel could also "fix" the problem.


The root problem is the "branch sync mechanism", it is incomplete in some cases (but at the moment I can't tell more .....), the cases need to be fixed one by one.

@wxiaoguang commented on GitHub (Jun 24, 2024): > This comment by a maintainer suggests, that when a default branch by the default name is missing That's only one case for the "branch sync" problem ..... > I can 100% confirm, that this is not the case. My repositories worked for all previous versions, then I switched to `1.22` and suddenly the system looks for a branch, that never existed in any of the repositories on my instance in the first place. No default branches have been ever re-assigned or even deleted. That's another case: some branches are out-of-sync for some known or unknown reasons, so "sync branches" on the admin dashboard panel could also "fix" the problem. ---- The root problem is the "branch sync mechanism", it is incomplete in some cases (but at the moment I can't tell more .....), the cases need to be fixed one by one.
Author
Owner

@theAkito commented on GitHub (Jun 24, 2024):

This comment by a maintainer suggests, that when a default branch by the default name is missing

That's only one case .....

I can 100% confirm, that this is not the case. My repositories worked for all previous versions, then I switched to 1.22 and suddenly the system looks for a branch, that never existed in any of the repositories on my instance in the first place. No default branches have been ever re-assigned or even deleted.

That's another case: some branches are out-of-sync for some known or unknown reasons, so "sync branches" on the admin dashboard panel could also "fix" the problem.

The root problem is the "branch sync mechanism", it is incomplete in some cases (but at the moment I can't tell more .....), the cases need to be fixed one by one.

I see. Thanks for the clarification.

However, even if it is out of sync, why does it search for a main branch?
The reason I'm asking is, is because it's so random and shows, that the branches of the particular repository were not even screened, at all.

@theAkito commented on GitHub (Jun 24, 2024): > > This comment by a maintainer suggests, that when a default branch by the default name is missing > > That's only one case ..... > > > I can 100% confirm, that this is not the case. My repositories worked for all previous versions, then I switched to `1.22` and suddenly the system looks for a branch, that never existed in any of the repositories on my instance in the first place. No default branches have been ever re-assigned or even deleted. > > That's another case: some branches are out-of-sync for some known or unknown reasons, so "sync branches" on the admin dashboard panel could also "fix" the problem. > > The root problem is the "branch sync mechanism", it is incomplete in some cases (but at the moment I can't tell more .....), the cases need to be fixed one by one. I see. Thanks for the clarification. However, even if it is out of sync, why does it search for a `main` branch? The reason I'm asking is, is because it's so random and shows, that the branches of the particular repository were not even screened, at all.
Author
Owner

@wxiaoguang commented on GitHub (Jun 24, 2024):

However, even if it is out of sync, why does it search for a main branch?

Because if a repo doesn't have a default branch, but the database might have recorded "main" as the default branch.

There could be some different causes:

  1. the repo itself doesn't really have a default branch, but database recorded value is "default_branch=main"
  2. the repo itself ever had a default branch, but the branch was renamed or deleted but the database record doesn't get update (just my guess)
  3. the repo itself ever had correct branches, but the database branches were not updated (and corrupted) due to some reasons then the branches recorded in database are out-of-sync of the real git branches (still just my guess)

More context: theoretically, the "branch list" should be correctly stored in a database table and used from that database table, the "default branch" is also stored in database. In most cases, the "branch list" and "default branch" in database should be the same as what in a git repo. However, sometimes "branch list" and "default branch" might differ from from the underlying git repo (surely it is a bug). Even the underlying repo doesn't really have a default branch, "default branch" could also be something like "main".

@wxiaoguang commented on GitHub (Jun 24, 2024): > However, even if it is out of sync, why does it search for a `main` branch? Because if a repo doesn't have a default branch, but the database might have recorded "main" as the default branch. There could be some different causes: 1. the repo itself doesn't really have a default branch, but database recorded value is "default_branch=main" 2. the repo itself ever had a default branch, but the branch was renamed or deleted but the database record doesn't get update (just my guess) 3. the repo itself ever had correct branches, but the database branches were not updated (and corrupted) due to some reasons then the branches recorded in database are out-of-sync of the real git branches (still just my guess) ---- More context: theoretically, the "branch list" should be correctly stored in a database table and used from that database table, the "default branch" is also stored in database. In most cases, the "branch list" and "default branch" in database should be the same as what in a git repo. However, sometimes "branch list" and "default branch" might differ from from the underlying git repo (surely it is a bug). Even the underlying repo doesn't really have a default branch, "default branch" could also be something like "main".
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13196