Deleting Issue via API causes internal server error when no git repo exists #10900

Closed
opened 2025-11-02 09:21:35 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @hakito on GitHub (May 23, 2023).

Originally assigned to: @wxiaoguang on GitHub.

Description

The API endpoint for issue deletion considers the git repo.

https://github.com/go-gitea/gitea/blob/8ceb78caad6c06fe66b27ca7c9b4144b3602e896/routers/api/v1/repo/issue.go#L883

But when no git repo has been created it causes a runtime error:

2023/05/23 13:27:34 ...common/middleware.go:72:1() [E] [646cbf46] PANIC: runtime error: invalid memory address or nil pointer dereference
  /usr/local/go/src/runtime/panic.go:260 (0x458adc)
  /usr/local/go/src/runtime/signal_unix.go:837 (0x458aac)
  /go/src/code.gitea.io/gitea/services/issue/issue.go:136 (0x1d5254d)
  /go/src/code.gitea.io/gitea/routers/api/v1/repo/issue.go:883 (0x2264413)
  /go/src/code.gitea.io/gitea/modules/web/wrap_convert.go:62 (0x2111093)
  /go/src/code.gitea.io/gitea/modules/web/wrap.go:40 (0x210f784)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:444 (0x182ad15)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/src/code.gitea.io/gitea/modules/web/wrap.go:97 (0x211020c)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/src/code.gitea.io/gitea/modules/web/wrap.go:97 (0x211020c)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/src/code.gitea.io/gitea/modules/context/api.go:252 (0x1c8f2d1)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/src/code.gitea.io/gitea/routers/api/v1/api.go:1288 (0x22b6073)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:73 (0x1828a94)
  /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:316 (0x182a4a3)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:444 (0x182ad15)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/src/code.gitea.io/gitea/routers/common/middleware.go:80 (0x2242ca2)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/src/code.gitea.io/gitea/modules/web/routing/logger_manager.go:122 (0x210b893)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/src/code.gitea.io/gitea/routers/common/middleware.go:112 (0x2241895)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/pkg/mod/github.com/chi-middleware/proxy@v1.1.1/middleware.go:37 (0x22405b6)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/src/code.gitea.io/gitea/routers/common/middleware.go:32 (0x2242af4)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:90 (0x1828a4f)
  /go/src/code.gitea.io/gitea/modules/web/route.go:191 (0x210ec6d)
  /usr/local/go/src/net/http/server.go:2936 (0x9bd495)
  /usr/local/go/src/net/http/server.go:1995 (0x9b89b1)
  /usr/local/go/src/runtime/asm_amd64.s:1598 (0x478b40)

Gitea Version

1.19.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Docker

Database

MySQL

Originally created by @hakito on GitHub (May 23, 2023). Originally assigned to: @wxiaoguang on GitHub. ### Description The API endpoint for issue deletion considers the git repo. https://github.com/go-gitea/gitea/blob/8ceb78caad6c06fe66b27ca7c9b4144b3602e896/routers/api/v1/repo/issue.go#L883 But when no git repo has been created it causes a runtime error: ``` 2023/05/23 13:27:34 ...common/middleware.go:72:1() [E] [646cbf46] PANIC: runtime error: invalid memory address or nil pointer dereference /usr/local/go/src/runtime/panic.go:260 (0x458adc) /usr/local/go/src/runtime/signal_unix.go:837 (0x458aac) /go/src/code.gitea.io/gitea/services/issue/issue.go:136 (0x1d5254d) /go/src/code.gitea.io/gitea/routers/api/v1/repo/issue.go:883 (0x2264413) /go/src/code.gitea.io/gitea/modules/web/wrap_convert.go:62 (0x2111093) /go/src/code.gitea.io/gitea/modules/web/wrap.go:40 (0x210f784) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:444 (0x182ad15) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/src/code.gitea.io/gitea/modules/web/wrap.go:97 (0x211020c) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/src/code.gitea.io/gitea/modules/web/wrap.go:97 (0x211020c) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/src/code.gitea.io/gitea/modules/context/api.go:252 (0x1c8f2d1) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/src/code.gitea.io/gitea/routers/api/v1/api.go:1288 (0x22b6073) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:73 (0x1828a94) /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:316 (0x182a4a3) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:444 (0x182ad15) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/src/code.gitea.io/gitea/routers/common/middleware.go:80 (0x2242ca2) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/src/code.gitea.io/gitea/modules/web/routing/logger_manager.go:122 (0x210b893) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/src/code.gitea.io/gitea/routers/common/middleware.go:112 (0x2241895) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/pkg/mod/github.com/chi-middleware/proxy@v1.1.1/middleware.go:37 (0x22405b6) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/src/code.gitea.io/gitea/routers/common/middleware.go:32 (0x2242af4) /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e) /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:90 (0x1828a4f) /go/src/code.gitea.io/gitea/modules/web/route.go:191 (0x210ec6d) /usr/local/go/src/net/http/server.go:2936 (0x9bd495) /usr/local/go/src/net/http/server.go:1995 (0x9b89b1) /usr/local/go/src/runtime/asm_amd64.s:1598 (0x478b40) ``` ### Gitea Version 1.19.3 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Docker ### Database MySQL
GiteaMirror added the type/bug label 2025-11-02 09:21:35 -06:00
Author
Owner

@wxiaoguang commented on GitHub (May 23, 2023):

It has been fixed in 1.20 by #24068

I guess 1.19 needs a new fix.

@wxiaoguang commented on GitHub (May 23, 2023): It has been fixed in 1.20 by #24068 I guess 1.19 needs a new fix.
Author
Owner

@wxiaoguang commented on GitHub (May 23, 2023):

-> Make DeleteIssue use correct context #24885

@wxiaoguang commented on GitHub (May 23, 2023): -> Make DeleteIssue use correct context #24885
Author
Owner

@wxiaoguang commented on GitHub (May 24, 2023):

#24885 is merged. Could you try to upgrade to 1.19 nightly?

https://hub.docker.com/r/gitea/gitea/tags?page=1&name=1.19-nightly

@wxiaoguang commented on GitHub (May 24, 2023): #24885 is merged. Could you try to upgrade to 1.19 nightly? https://hub.docker.com/r/gitea/gitea/tags?page=1&name=1.19-nightly
Author
Owner

@hakito commented on GitHub (May 24, 2023):

Thanks, it works with the nightly build!

@hakito commented on GitHub (May 24, 2023): Thanks, it works with the nightly build!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10900