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

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

Closed
hakito opened this issue May 23, 2023 · 4 comments
Closed
Assignees
Labels

Comments

@hakito
Copy link
Contributor

hakito commented May 23, 2023

Description

The API endpoint for issue deletion considers the git repo.

if err = issue_service.DeleteIssue(ctx.Doer, ctx.Repo.GitRepo, issue); err != nil {

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/[email protected]/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/[email protected]/mux.go:73 (0x1828a94)
  /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:316 (0x182a4a3)
  /usr/local/go/src/net/http/server.go:2122 (0x9b9e8e)
  /go/pkg/mod/github.com/go-chi/chi/[email protected]/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/[email protected]/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/[email protected]/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

@wxiaoguang
Copy link
Contributor

It has been fixed in 1.20 by #24068

I guess 1.19 needs a new fix.

@wxiaoguang
Copy link
Contributor

-> Make DeleteIssue use correct context #24885

techknowlogick pushed a commit that referenced this issue May 23, 2023
Fix #24884 , the `ctx.Repo.GitRepo` might be nil.
@wxiaoguang
Copy link
Contributor

#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

@hakito
Copy link
Contributor Author

hakito commented May 24, 2023

Thanks, it works with the nightly build!

Codeberg-org pushed a commit to Codeberg-org/gitea that referenced this issue Jun 3, 2023
Fix go-gitea#24884 , the `ctx.Repo.GitRepo` might be nil.

(cherry picked from commit d19d5bc)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants