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

"git cat-file: could not get object info" in webui #6525

Open
fphammerle opened this issue Mar 19, 2021 · 5 comments
Open

"git cat-file: could not get object info" in webui #6525

fphammerle opened this issue Mar 19, 2021 · 5 comments

Comments

@fphammerle
Copy link

Describe the bug

Gogs responds to requests to https://git.hammerle.me/kjhammerle/cube-game-plus-plus/commit/914108b98f3ce4417f2af5b8b55a09fd68e8ed3f
with HTTP 500 and the following response body:

template: repo/diff/box:81:20: executing "repo/diff/box" at <call $.IsImageFileByIndex $file.Index>: error calling call: exit status 128 - fatal: git cat-file: could not get object info

I see no apparent reason why that particular commit would be invalid.

The tree view for the same commit works as expected: https://git.hammerle.me/kjhammerle/cube-game-plus-plus/src/914108b98f3ce4417f2af5b8b55a09fd68e8ed3f

Gogs version and commit

Application version: 0.12.3
Build commit: f0e3cd90f8d7695960eeef2e4e54b2e717302f6c 

Git version

$ git version
git version 2.30.2

Operating system

running docker.io/gogs/gogs@sha256:0195b095d0b29e5fd9fd44c0e4a544c981f8c8b2b7fb18ca61824694e31d279e via docker

Database
sqlite3

To Reproduce

  1. Open https://git.hammerle.me/kjhammerle/cube-game-plus-plus/commit/914108b98f3ce4417f2af5b8b55a09fd68e8ed3f
  2. Browser will show the error mentioned above

Can you reproduce the bug at https://try.gogs.io?
Different error on try.gogs.io, see https://try.gogs.io/fphammerle/cube-game-plus-plus/commit/914108b98f3ce4417f2af5b8b55a09fd68e8ed3f

template: repo/diff/box:81:20: executing "repo/diff/box" at <call $.IsImageFileByIndex $file.Index>: error calling call: exit status 128 - error: unable to find c187e25ecdba5875f5765acc967e35017985629e
fatal: git cat-file c187e25ecdba5875f5765acc967e35017985629e: bad file

Expected behavior
Webpage showing diff of commit, like https://git.hammerle.me/kjhammerle/cube-game-plus-plus/commit/5b06c611e21f994d38bb34ff1488f5ee0227d45d

Actual behavior
HTTP500 response with

template: repo/diff/box:81:20: executing "repo/diff/box" at <call $.IsImageFileByIndex $file.Index>: error calling call: exit status 128 - fatal: git cat-file: could not get object info

(no gogs UI)

Additional context
No new entry in log/gogs.log when accessing mentioned url.

@fphammerle
Copy link
Author

I just tracked the git commands executed by gogs with

$ sudo strace -v -s64 -f -e execve -p $(pgrep gogs) 2>&1  | grep -oP 'cat-file.*?\]'

The responsible git command seems to be:

$ sudo docker exec -it -u git gogs bash
bash-5.0$ cd /data/git/gogs-repositories/kjhammerle/cube-game-plus-plus.git
bash-5.0$ git cat-file -t c187e25ecdba5875f5765acc967e35017985629e
fatal: git cat-file: could not get object info
bash-5.0$ 

@fphammerle
Copy link
Author

c187e25ecdba5875f5765acc967e35017985629e is the commit hash of a just deleted submodule:

$ sudo docker exec -it -u git gogs bash
bash-5.0$ cd /data/git/gogs-repositories/kjhammerle/cube-game-plus-plus.gitbash-5.0$ git diff --full-index -M 5b06c611e21f994d38bb34ff1488f5ee0227d45d 914108b98f3ce4417f2af5b8b55a09fd68e8ed3f | grep -B 2 c187e25ecdba5875f5765acc967e35017985629e
diff --git a/enet b/enet
deleted file mode 160000
index c187e25ecdba5875f5765acc967e35017985629e..0000000000000000000000000000000000000000
--
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit c187e25ecdba5875f5765acc967e35017985629e
bash-5.0$ 

@fphammerle
Copy link
Author

so in summary:

the issue is caused by gogs executing git cat-file -t c187e25ecdba5875f5765acc967e35017985629e

the git cat-file commands fails because c187e25ecdba5875f5765acc967e35017985629e is actually a commit in different repository ( zpl-c/enet@c187e25 ) that we previously included as a git submodule

@fphammerle
Copy link
Author

fphammerle commented Mar 19, 2021

associated source code:

{{if $file.IsDeleted}}
	{{$isImage = (call $.IsImageFileByIndex $file.Index)}}
{{else}}

in https://github.com/gogs/gogs/blob/v0.12.3/templates/repo/diff/box.tmpl#L81

@fphammerle
Copy link
Author

associated:

// IsImageFileByIndex returns true if the blob of the commit is an image by index.
func (c *Commit) IsImageFileByIndex(index string) (bool, error) {
	return c.isImageFile(c.BlobByIndex(index))
}

https://github.com/gogs/git-module/blob/v1.1.4/commit.go#L170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant