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

"api/v1/repos" panic when mirroring a repo #22452

Closed
jim3ma opened this issue Jan 15, 2023 · 2 comments · Fixed by #22457
Closed

"api/v1/repos" panic when mirroring a repo #22452

jim3ma opened this issue Jan 15, 2023 · 2 comments · Fixed by #22457
Labels

Comments

@jim3ma
Copy link

jim3ma commented Jan 15, 2023

Description

Panic when mirroring a repo, like: https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git

/api/v1/repos/mirrors/linux-stable-rt/git/trees/main?recursive=1

2023/01/15 02:34:11 ...common/middleware.go:71:1() [E] [63c36623-2] PANIC: runtime error: invalid memory address or nil pointer dereference
	/usr/local/go/src/runtime/panic.go:260 (0x459655)
	/usr/local/go/src/runtime/signal_unix.go:835 (0x459625)
	/go/src/code.gitea.io/gitea/modules/git/repo_commit_nogogit.go:37 (0xfed976)
	/go/src/code.gitea.io/gitea/modules/git/repo_tree_nogogit.go:71 (0x10064b6)
	/go/src/code.gitea.io/gitea/services/repository/files/tree.go:21 (0x1f8da86)
	/go/src/code.gitea.io/gitea/routers/api/v1/repo/tree.go:63 (0x1fdd753)
	/go/src/code.gitea.io/gitea/modules/web/wrap_convert.go:63 (0x1ecf3b3)
	/go/src/code.gitea.io/gitea/modules/web/wrap.go:41 (0x1ecda84)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 (0x1abf735)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/src/code.gitea.io/gitea/modules/web/wrap.go:98 (0x1ece50c)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/src/code.gitea.io/gitea/modules/web/wrap.go:98 (0x1ece50c)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/src/code.gitea.io/gitea/modules/context/api.go:283 (0x1acabf1)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/src/code.gitea.io/gitea/routers/api/v1/api.go:1186 (0x200a853)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:71 (0x1abd4f4)
	/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:314 (0x1abeefb)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 (0x1abf735)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/src/code.gitea.io/gitea/routers/common/middleware.go:79 (0x1f9a362)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/src/code.gitea.io/gitea/modules/web/routing/logger_manager.go:123 (0x1ec9793)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/pkg/mod/github.com/go-chi/chi/[email protected]/middleware/strip.go:30 (0x1f97bf8)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/pkg/mod/github.com/chi-middleware/[email protected]/middleware.go:37 (0x1f94396)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/src/code.gitea.io/gitea/routers/common/middleware.go:32 (0x1f9a1b1)
	/usr/local/go/src/net/http/server.go:2109 (0x94ffee)
	/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:88 (0x1abd4af)
	/go/src/code.gitea.io/gitea/modules/web/route.go:200 (0x1eccead)
	/usr/local/go/src/net/http/server.go:2947 (0x9533eb)
	/usr/local/go/src/net/http/server.go:1991 (0x94eac6)
	/usr/local/go/src/runtime/asm_amd64.s:1594 (0x477320)

2023/01/15 02:34:11 [63c36623-2] router: failed    GET /api/v1/repos/mirrors/linux-stable-rt/git/trees/main?recursive=1 for 10.42.0.1:42594, panic in 4.3ms @ repo/tree.go:15(repo.GetTree), err=runtime error: invalid memory address or nil pointer dereference

Gitea Version

1.18.0

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

helm

Database

MySQL

zeripath added a commit to zeripath/gitea that referenced this issue Jan 15, 2023
The API endpoints for "git" can panic if they are called on an empty repo. We can simply allow
empty repos for these endpoints without worry as they should just work.

Fix go-gitea#22452

Signed-off-by: Andrew Thornton <[email protected]>
@zeripath
Copy link
Contributor

I'm not sure why you're trying to mirror an empty repository... but of course these endpoint should not panic.

jolheiser pushed a commit that referenced this issue Jan 15, 2023
The API endpoints for "git" can panic if they are called on an empty
repo. We can simply allow empty repos for these endpoints without worry
as they should just work.

Fix #22452

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit to zeripath/gitea that referenced this issue Jan 15, 2023
…itea#22457)

Backport go-gitea#22457

The API endpoints for "git" can panic if they are called on an empty
repo. We can simply allow empty repos for these endpoints without worry
as they should just work.

Fix go-gitea#22452

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit that referenced this issue Jan 15, 2023
…) (#22458)

Backport #22457

The API endpoints for "git" can panic if they are called on an empty
repo. We can simply allow empty repos for these endpoints without worry
as they should just work.

Fix #22452

Signed-off-by: Andrew Thornton <[email protected]>
@jim3ma
Copy link
Author

jim3ma commented Jan 16, 2023

I'm not sure why you're trying to mirror an empty repository... but of course these endpoint should not panic.

Not empty, the repo is doing the mirror action, so it looks like empty.

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants