go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.17k stars 5.42k forks source link

Git LFS hooks are recreated server-side when the repository has custom hooks #31960

Open na-Itms opened 2 weeks ago

na-Itms commented 2 weeks ago

Description

This issue is similar to #19810 and #23765.

Whenever I try to create a PR from a branch on the same repository ("merge into repo:main / pull from repo:branch"), I receive the infamous error batch request: missing protocol: "".

The error is caused by Git LFS hooks getting installed on the repo server-side. Deleting them temporarily fixes the error and allows me to create the PR.

I noticed after a while that the issue arises as soon as the repo of the origin branch contains custom hooks (in our case, under update.d. Other repos do not face the issue.

Additionally, as soon as the PR is created (from a branch suffering from the problem), the LFS hooks get recreated.

Gitea Version

1.22.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.43.5

Operating System

AlmaLinux 9

How are you running Gitea?

Install from binary, run with systemd

Database

MySQL/MariaDB

na-Itms commented 2 days ago

It looks like the issue does not stem from PRs being "same-repository" PRs: I get the issue on all origin repos where a server-side custom hook is installed (in our case, under update.d).

I edited the OP.

lunny commented 1 day ago

Did you mean a new hook file created under update.d after a pull request created? Can you paste the content of this new-installed hook file?

na-Itms commented 19 hours ago

Did you mean a new hook file created under update.d after a pull request created? Can you paste the content of this new-installed hook file?

Hello @lunny, no, the files that are created and cause the issue are the post-checkout, post-commit, post-merge and pre-push LFS hooks. However, I discovered that those are only created in the repos where we installed our own custom hooks under update.d.

By typing this I think I know what the issue is. One of our update.d hooks checks that no raw binary files were pushed by users who haven't installed git-lfs. This hook runs the git-lfs-fsck command to verify the integrity of the LFS tracking. I believe this command is the one causing the LFS hooks to be recreated.

How should we move forward to avoid the batch request: missing protocol: "" error?