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

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

Closed
2 of 6 tasks
DHentzschel opened this issue Jul 8, 2021 · 11 comments
Closed
2 of 6 tasks

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

DHentzschel opened this issue Jul 8, 2021 · 11 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/bug

Comments

@DHentzschel
Copy link

DHentzschel commented Jul 8, 2021

  • Gitea version (or commit ref): 1.14.4
  • Git version: 2.20.1
  • Operating system: Raspberry Pi OS Debian buster
  • Binaries: from the official release page on GitHub
  • How I run gitea: via systemd
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist: related output

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:

  • Resynchronize pre-receive, update and post-receive hooks of all repositories.
  • Reinitialize all missing Git repositories for which records exist

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

noerw commented Jul 10, 2021

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 noerw added type/bug issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail labels Jul 10, 2021
@noerw
Copy link
Member

noerw commented Jul 13, 2021

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

DHentzschel commented Jul 15, 2021

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

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

DHentzschel commented Jul 15, 2021

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

zeripath commented Jul 16, 2021

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

DHentzschel commented Jul 16, 2021

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

zeripath commented Aug 8, 2021

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

zeripath commented Aug 8, 2021

See #13910

@DHentzschel
Copy link
Author

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

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.

@zeripath zeripath changed the title Opening a PR leads to 500 status Opening a PR leads to 500 status - due to lfs hooks Oct 28, 2021
@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
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/bug
Projects
None yet
Development

No branches or pull requests

3 participants