mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-10 22:06:34 -05:00
Gitea: Internal error retrieve protected branches information failed: EOF #3992
Closed
opened 2025-11-02 05:33:10 -06:00 by GiteaMirror
·
31 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16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3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#3992
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @randyesq on GitHub (Sep 20, 2019).
[x]):Description
We are hitting the following error very frequently when pushing from our local git repository to Gitea. Gitea is running in its docker image in Kubernetes.
From the local system pushing the branch:
The gitea server logs running in the pod show the following:
Here is our app.ini:
The only thing that can be done to unwedge this is to restart the pod running the gitea server. It appears as though the problem only happens when gitea is first deployed. After restarting the pod, we never see this issue again.
Possibly important is that we do not setup SSH at all, only https. The push failures occurs after cloning the repository using https, and pushing back using https.
@randyesq commented on GitHub (Sep 20, 2019):
Note that our
LOCAL_ROOT_URLis hard-coded tohttp://localhost:3000/as was suggested in #3226, #1685, #2270, and #7630. The restart seems to be working for others with different problems that have a similar error signature (#2851).@randyesq commented on GitHub (Sep 20, 2019):
I also have run the admin Maintenance Operations task titled "Resynchronize pre-receive, update and post-receive hooks of all repositories." and this did not fix anything.
@techknowlogick commented on GitHub (Sep 20, 2019):
This may have been fixed in a more recent version of Gitea (we just released 1.9.3). The newer versions also have patched some security vulns that are in 1.7.
1.9 also has improved logging to assist with debugging.
@randyesq commented on GitHub (Sep 20, 2019):
@techknowlogick is there something in the diff between 1.7 -> 1.9 that would suggest this would be fixed? From most of the issues that I referred to, it didn't seem like it was understood why this was even happening in the first place.
@techknowlogick commented on GitHub (Sep 20, 2019):
Potentially there could be something that has been added as there has been hundreds of PRs since 1.7. It could be a timeout issue with the DB, and we've updated upstream dependencies, it could be an uncaught error that is now handled, it could be many things. We've also significantly refactored working with the underlying git repos which may be a factor. Please see the entire list of changes here: https://github.com/go-gitea/gitea/blob/master/CHANGELOG.md
I recommend updating and to see if this still happens, especially since there are several CVEs in the version you are currently using: https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=gitea Once you've updated the logging in v1.9.3 is really improved and can give a ton of details about what could be happening.
@randyesq commented on GitHub (Sep 20, 2019):
Okay, we'll get on with upgrading this on our side and see if anything else comes up.
@devurandom commented on GitHub (Nov 1, 2019):
In my case it worked. I also pressed the ".ssh/authorized_keys" button, so maybe that had some effect, too.
@zeripath commented on GitHub (Nov 1, 2019):
yeah that would need changing too if you changed the path of the gitea binary.
To be clear Gitea has to write its real full path to:
gitea-repositories/*.git/hooks/pre-receive.d/giteagitea-repositories/*.git/hooks/update.d/giteagitea-repositories/*.git/hooks/post-receive.d/gitea.ssh/authorized_keys(if you are not using the internal SSH or an AuthorizedKeysCommand)These all have to be updated if you change the path of the Gitea binary.
If you are moving from Gogs you may have to remove any reference to Gogs within the
gitea-repositories/*.git/hooks/*.ddirectories.It really is simpler not to change the name of the binary.
@randyesq commented on GitHub (Nov 1, 2019):
We encountered this issue in a K8S pod using v1.9.3 today.
@zeripath commented on GitHub (Nov 1, 2019):
@randyesq in order to diagnose I need to see what the message underlying that was and what your main Gitea logs show.
The problem here as originally stated cannot happen on 1.9 because those internal endpoints do not exist. I deleted them - (and now constantly regret doing so instead of coming up with an error saying you need to update although I remain uncertain how that helpful that would be as it could only be on the server.)
If your Gitea serv is requesting those end points e.g.
/api/internal/branch/1/mfischthen you have got an old version of Gitea running somewhere and you need to do hunt it down.Otherwise it's a different problem.
@randyesq commented on GitHub (Nov 2, 2019):
Here is the version of gitea that we are using:
Unfortunately, I don't have the server logs because they have rolled over since, but the output from the git client that was trying to force push the branch was:
@zeripath commented on GitHub (Nov 2, 2019):
Without those logs we can't tell you anything.
All you can say is that there was a pre-receive decline - that could be because you were force pushing to a protected branch and that was disallowed although the EOF implies that's not.
It could be a bug in /api/internal/hook/pre-receive or it could be that you've got an old Gitea hanging around that's trying to get to the old endpoints.
This last is the most likely so double check there aren't some seriously old Giteas hanging around and:
Ensure that your .SSH/authorized_keys always refers to the correct version of Gitea if there are multiple versions available, and ensure that your hooks are all doing similarly.
If it happens again grab the logs. If you're getting requests to /api/internal/branch then there's an old Gitea around. If not you've found a bug and we need the logs.
@randyesq commented on GitHub (Nov 4, 2019):
How do I ensure this?
@zeripath commented on GitHub (Nov 4, 2019):
The 2 admin tasks described above rewrite both of these things - however I can imagine a deployment style that would make those not work. It's your deployment - you tell me.
All I can say is to run those tasks, make sure there's not a rogue old version of Gitea in your container(s) or an old container still knocking around, and check those files.
If your Gitea serv is requesting /api/internal/branch that Gitea is not version 1.9 and it's out of date.
Further don't put multiple versions of Gitea in your containers. If you're using a script to wrap Gitea you should run Gitea with exec -a the_name_of_the_script as we use the $0 passed to Gitea as its path when writing hooks and authorized_keys.
@randyesq commented on GitHub (Nov 4, 2019):
Okay thanks, we only have one version of gitea, whatever is in the gitea/1.9.3 docker image from Docker hub, so I don't think it is a version issue.
@lunny commented on GitHub (Nov 5, 2019):
It seems you have a subpath of your domain setting, maybe it's related.
https://api-gw-service-nmn.local/vcs/cray/config-management.git.@randyesq commented on GitHub (Nov 7, 2019):
Okay, I had this happen today. I am running v1.9.3 and logged in to the web UI, created an org, created a repo (initialized it with the checkbox), and attempted to create a file in the UI. Here is the server log:
Looks like
is the problem area.
Note, the user is created by the gitea admin CLI when gitea is brought up.
@zeripath commented on GitHub (Nov 8, 2019):
Ok a status forbidden in hook pre-receive code is preceded by a warning.
So the forbidden is happening at:
4a08d574cf/routers/private/internal.go (L17-L24)Meaning that the internal token being passed to the server from the running command is incorrect.
You have different internal tokens - they all have to be the same.
@randyesq commented on GitHub (Nov 11, 2019):
So this action was run from the UI from a logged in user. Are you saying that something that is being done with my configuration of gitea itself is wrong, or something in the UI is wrong?
@zeripath commented on GitHub (Nov 11, 2019):
OK, I think it's time I stepped back down to what goes on when you do any git alterations in Gitea.
gitea hookwhich then transmits all of its data to the Gitea server.Now if you go and take a look at one of your gitea-repositories you'll see that the hooks are something like:
Note the absolute path to the gitea application that run it, and a config file reference.
The config file reference is important because gitea will not be unlikely to find its config otherwise, in particular it needs the
INTERNAL_TOKENfrom that app.ini because, well that's the authorization token that gitea hook uses to talk to the server and it needs find the local address for the Gitea server to speak to (That's specifically LOCAL_ROOT_URL, but ROOT_URL, or whatever goes to make that if that's not set.)Now as I state above, there is no place for a user to get Forbidden in hooks without some more logging except at:
4a08d574cf/routers/private/internal.go (L17-L24)So, when that push is happening the config that the hook files is finding is not correct - either because INTERNAL_TOKEN is not set or the server that hook speaks to over LOCAL_ROOT_URL has a different INTERNAL_TOKEN.
@randyesq commented on GitHub (Nov 11, 2019):
Is there a way I can modify the
pre-receive.d/giteabash script to print out the values of the INTERNAL_TOKEN that are in play?@zeripath commented on GitHub (Nov 11, 2019):
A grep of the config file as a hook would do it as far as I can see.
@randyesq commented on GitHub (Nov 11, 2019):
Where would the output of that hook script end up for me to review?
@zeripath commented on GitHub (Nov 11, 2019):
Stdout from most git hooks is sent directly to the client. Certainly these would do so.
The issue is ensuring that you're getting exactly the same config file as the hook - you could grep/sed it out of the Gitea hook file.
However if you can do all that, I'm not certain just checking hook files and container confs would not work.
If you don't want it to go to the client - one trick is to do a wget to get it into a server log.
@randyesq commented on GitHub (Nov 11, 2019):
Okay, well the instance for the server logs that I found was running in a VM that I have up that has the same configuration as our regular setup, here is the content of the hook and shows that the
app.iniandgiteaexecutable are where I expect them to be:My
app.inidoes not include anINTERNAL_TOKENwhen Gitea first starts up, but it looks like Gitea is creating one properlyLOCAL_ROOT_URLandROOT_URLare defined as such in the server section ofapp.ini:Anything you see here look incorrect?
@zeripath commented on GitHub (Nov 12, 2019):
I don't know your configuration but I suspect app.ini having internal token empty is incorrect. Do you ever have more than one Gitea running at a time?
Is it possible that the instance that is running the hook is not the same instance as the Gitea that is the server?
Stop recreating the internal token every time. Put it in the app.ini.
@randyesq commented on GitHub (Nov 13, 2019):
We don't have more than one instance running at a time, so that is not possible.
I'll see about adding an internal token when we bring up gitea the first time. My question would be, however, is the internal token changing while gitea is up and running?
@randyesq commented on GitHub (Nov 21, 2019):
Is there a specific format for the internal token that needs to be used?
@zeripath commented on GitHub (Nov 21, 2019):
Not sure but I could imagine that if the server was restarted for whatever reason the internal token would change.
I think you just need to copy a created internal token from the app.ini of a running server and add that to your template.
@stale[bot] commented on GitHub (Jan 21, 2020):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@randyesq commented on GitHub (Jan 21, 2020):
We have made the change to have the INTERNAL_TOKEN set when the instance is first brought up. Haven't seen any issues since then. Thanks for your help on this one @zeripath .