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.61k stars 5.45k forks source link

Opening a PR leads to 500 status - due to lfs hooks #16372

Closed DHentzschel closed 2 years ago

DHentzschel commented 3 years ago

Description

When trying to open a PR from develop to master branch in a private, simple and small repo, Gitea returns 500. After enabling debug and trace mode and retrying the same step, gitea's frontend prints the following message:

Push: <org>/<repo>:develop <org>/<repo>:refs/pull/18/head exit status 1 - Invalid remote name "/<path>/<to>/<org>/<repo>.git": Invalid remote name: "/<path>/<to>/<org>/<repo>.git" error: failed to push some refs to '/<path>/<to>/<org>/<repo>.git'

When calling the defective PR, a message appears This pull request is broken due to missing fork information.

I've run the following tasks trying to fix it the issue:

There actually were no manual steps I did to modify the repo.

Edit (16 July 2021) So, reproduced the issue and checked the logs in dev mode and with log level trace.

The following logs have been written: Note: User, organisation, repo names and repo directory have been exchanged by myuser, myorganisation/myrepo and /path/to/repos

Frontend

Push: myorganisation/myrepo:develop myorganisation/myrepo:refs/pull/25/head exit status 1 - Invalid remote name "/path/to/repos/myorganisation/myrepo.git": Invalid remote name: "/path/to/repos/myorganisation/myrepo.git" error: failed to push some refs to '/path/to/repos/myorganisation/myrepo.git'

Backend See gitea.log

Edit 2 (16 July 2021) The project exists and is a git repo.

After using the config parameters from the comments the following got printed to the console: console.log The only thing I've sanitized are organisation name, repo name and IP address (CSFR token also)

I've preserved its integrity.

By the way, after getting this error, a new pull request will be created and displayed like this: frontend_n-a I can only create a new PR for both branches develop -> master when the defect one is closed.

Screenshots

noerw commented 3 years ago

Hi, please provider server side logs, ideally from when you created the PR, and when visiting the PR page. Otherwise it's hard to debug the problem

noerw commented 3 years ago

@DHentzschel Can you verify the path /<path>/<to>/<org>/<repo>.git exists and is readwriteable by the gitea user? Does it by chance contain special characters, spaces, or other potentially problematic stuff?

DHentzschel commented 3 years ago

Hi, please provider server side logs, ideally from when you created the PR, and when visiting the PR page. Otherwise it's hard to debug the problem

Hello, what log files could I provide in addition?

@DHentzschel Can you verify the path /<path>/<to>/<org>/<repo>.git exists and is readwriteable by the gitea user? Does it by chance contain special characters, spaces, or other potentially problematic stuff?

The path i.e. repo exists. I also can work with the repo local and push it to gitea but as soon as I want to open a PR, a 500 status code will be returned. I am using an administrator account (repo owner so full R/W permissions) so it should work without any problem.

zeripath commented 3 years ago
2021/07/08 11:55:06 ...ervices/pull/pull.go:431:PushToBaseRepo() [E] Unable to push PR head for /#10 (183:/:refs/pull/10/head) due to Error: exit status 1 - Invalid remote name "///.git": Invalid remote name: "////.git"
error: failed to push some refs to '////.git'

2021/07/08 11:55:06 routers/repo/pull.go:1081:CompareAndPullRequestPost() [E] NewPullRequest: Push: /:develop /:refs/pull/10/head exit status 1 - Invalid remote name "////.git": Invalid remote name: "////.git"
error: failed to push some refs to '////.git'

2021/07/08 11:55:12 ...ervices/pull/pull.go:680:GetIssuesLastCommitStatus() [E] getLastCommitStatus: cant get last commit of pull [213]: object does not exist [id: refs/pull/10/head, rel_path: ]

have you sanitized these logs to remove the owner and reponames?

DHentzschel commented 3 years ago
2021/07/08 11:55:06 ...ervices/pull/pull.go:431:PushToBaseRepo() [E] Unable to push PR head for /#10 (183:/:refs/pull/10/head) due to Error: exit status 1 - Invalid remote name "///.git": Invalid remote name: "////.git"
error: failed to push some refs to '////.git'

2021/07/08 11:55:06 routers/repo/pull.go:1081:CompareAndPullRequestPost() [E] NewPullRequest: Push: /:develop /:refs/pull/10/head exit status 1 - Invalid remote name "////.git": Invalid remote name: "////.git"
error: failed to push some refs to '////.git'

2021/07/08 11:55:12 ...ervices/pull/pull.go:680:GetIssuesLastCommitStatus() [E] getLastCommitStatus: cant get last commit of pull [213]: object does not exist [id: refs/pull/10/head, rel_path: ]

have you sanitized these logs to remove the owner and reponames? Originally no, I did not remove parts of the logs. So, reproduced the issue and checked the logs in dev mode and with log level trace.

The following (full) logs have been written: Note: User, organisation, repo names and repo directory have been exchanged by myuser, myorganisation/myrepo and /path/to/repos

Frontend

Push: myorganisation/myrepo:develop myorganisation/myrepo:refs/pull/25/head exit status 1 - Invalid remote name "/path/to/repos/myorganisation/myrepo.git": Invalid remote name: "/path/to/repos/myorganisation/myrepo.git" error: failed to push some refs to '/path/to/repos/myorganisation/myrepo.git'

Backend See gitea.log

zeripath commented 3 years ago

@DHentzschel I think we're going to need to see the command that gets sent to git .

However, first please ensure that /path/to/repos/myorganisation/myrepo.git actually exists on your system, is a git repository and has the correct permissions.


If you're certain that it exists and is a git repo then:

Change your app.ini to set the following:

RUN_MODE=dev # This is important as it will give us git command logging

...
[database]
LOG_SQL=false # We don't need to see SQL statements

...

[log]
MODE      = console 
LEVEL= debug
REDIRECT_MACARON_LOG=true
MACARON=console
ROUTER=console
XORM=console

and then try to do the push again...

Then give us the full logs. If you have to sanitize please really only sanitize the absolute minimum.

Please note in the above configuration I am sending everything console for a reason. I need to see how things interleave. If you send these to files they will lose the interleaving and the git logs only get sent to the console anyway. (in 1.14 and lower - 1.15 will be better in this regard.)

DHentzschel commented 3 years ago

@zeripath The project exists and is a git repo.

After using your config parameters the following got printed to the console: console.log The only things I've sanitized are organisation name, repo name and IP address (CSFR token also)

I've preserved its integrity.

By the way, after getting this error, a new pull request will be created and displayed like this: frontend_n-a I can only create a new PR for both branches develop -> master when the defect one is closed.

zeripath commented 3 years ago

AHA! I've worked this out.

This is not coming from git it's coming from git lfs

Somehow you have raw git lfs hooks in your gitea repositories. You need to remove these. They shouldn't be there.

zeripath commented 3 years ago

See #13910

DHentzschel commented 3 years ago

AHA! I've worked this out.

This is not coming from git it's coming from git lfs

Somehow you have raw git lfs hooks in your gitea repositories. You need to remove these. They shouldn't be there.

Glad to hear you figured it out. How do I remove those hooks and how do I avoid the same incidence in the future?

zeripath commented 2 years ago

agh I missed this - you need to go into the repos on the filesystem and remove the git lfs hooks from the hooks directory.

git lfs will have more information.