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

Edit issue API returns 500 #32030

Closed
dimasrespect opened this issue Sep 12, 2024 · 5 comments · Fixed by #32035
Closed

Edit issue API returns 500 #32030

dimasrespect opened this issue Sep 12, 2024 · 5 comments · Fixed by #32035
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented topic/api Concerns mainly the API type/bug
Milestone

Comments

@dimasrespect
Copy link

Description

When using API endpoint: PATCH /repos/{owner}/{repo}/issues/{index} server returns 500 (internal server error):

PANIC: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:785 (0x477751)
/source/modules/web/routing/logger_manager.go:116 (0x1e85ba8)
/usr/local/go/src/runtime/panic.go:785 (0x477751)
/usr/local/go/src/runtime/panic.go:262 (0x479bd8)
/usr/local/go/src/runtime/signal_unix.go:900 (0x479ba8)
/source/routers/api/v1/repo/issue.go:836 (0x29dbd9a)
/usr/local/go/src/reflect/value.go:581 (0x504ea5)
/usr/local/go/src/reflect/value.go:365 (0x503fb8)
/source/modules/web/handler.go:172 (0x1e8f63c)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:182 (0x1e8f6db)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:182 (0x1e8f6db)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:182 (0x1e8f6db)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:182 (0x1e8f6db)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:182 (0x1e8f6db)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:182 (0x1e8f6db)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/chain.go:31 (0x1e86485)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:459 (0x1e89421)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:182 (0x1e8f6db)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:182 (0x1e8f6db)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:182 (0x1e8f6db)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/services/context/api.go:238 (0x2a599bd)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:136 (0x1e8fad9)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/routers/api/v1/api.go:1615 (0x2a59556)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:136 (0x1e8fad9)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:73 (0x1e8702e)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:327 (0x1e889ba)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:459 (0x1e89421)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/routing/logger_manager.go:122 (0x1e85a38)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:136 (0x1e8fad9)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/go/pkg/mod/github.com/chi-middleware/[email protected]/middleware.go:37 (0x29b2a93)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:136 (0x1e8fad9)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/routers/common/middleware.go:59 (0x29b3c6f)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:136 (0x1e8fad9)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/routers/common/middleware.go:50 (0x29b37fb)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:136 (0x1e8fad9)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/routers/common/middleware.go:36 (0x29b3429)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/source/modules/web/handler.go:136 (0x1e8fad9)
/usr/local/go/src/net/http/server.go:2220 (0x96c328)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:90 (0x1e86fed)
/source/modules/web/route.go:225 (0x1e9133b)
/source/modules/web/route.go:165 (0x1e90e64)
/usr/local/go/src/net/http/server.go:3210 (0x98c88d)
/usr/local/go/src/net/http/server.go:2092 (0x96accf)
/usr/local/go/src/runtime/asm_amd64.s:1700 (0x480160)

Gitea Version

1.22.2

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

2.30.2

Operating System

Debian

How are you running Gitea?

Was tested on demo.gitea.com, latest release and latest nightly build. Error is everywhere.

Database

PostgreSQL

@techknowlogick techknowlogick added the topic/api Concerns mainly the API label Sep 12, 2024
@techknowlogick
Copy link
Member

Thanks for the report, are you able to share an example of the contents of the PATCH payload?

@dimasrespect
Copy link
Author

I think, i found the problem. It's here:

if (form.RemoveDeadline == nil || !*form.RemoveDeadline) && !form.Deadline.IsZero() {

Some additional check is required here. I'm making request with "unset_due_date": false and i'm not providing due_date field. In this case form.Deadline is undefined and error happens. So there are should be additional check, something like this:
if (form.RemoveDeadline == nil || !*form.RemoveDeadline) && form.Deadline != nil && !form.Deadline.IsZero() {

@dimasrespect
Copy link
Author

Here is sample payload to reproduce issue:
{ "assignee": "user_login", "assignees": [ "user_login" ], "body": "custom comment", "milestone": 0, "title": "Edited issue", "unset_due_date": false }

@dimasrespect
Copy link
Author

Or may be it should return 412 error (bad request) in this case? So can understand that i'm doing something wrong ;)

@Zettat123 Zettat123 added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Sep 13, 2024
@Zettat123
Copy link
Contributor

I think a 400 error should be returned if the unset_due_date is set to false without providing a due_date

@lunny lunny added this to the 1.22.3 milestone Sep 13, 2024
lunny pushed a commit that referenced this issue Sep 14, 2024
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented topic/api Concerns mainly the API type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants