curl -X GET "https://gitea.com/api/v1/repos/gitea/tea/pulls?state=closed&milestone=538&page=1" -H "accept: application/json"
since no trace or debug info is shown and I cant reproduce on my test instance I cant veryfy or determine the reason :/
current version of gitea.com: 1.12.0+dev-435-g6a57364dc
I can narrow the bug conditions:
This only occurs when the repo has a (closed?) PR, whose head branch has been deleted.
Can reproduce on current try.gitea.io and on gitea.com
@lunny can this be introduced by #10413?
Maybe #10618 is related?
@guillep2k that code doesn't run on the API - but perhaps a similar fix is needed for API.
@noerw are you able to give us a minimal testcase to reproduce?
OK curl -X GET "https://gitea.com/api/v1/repos/gitea/tea/pulls/106" -H "accept: application/json"
also gives a 500
Replicated
2020/03/08 21:32:26 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:199 (0x44c73b)
panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:394 (0x44c578)
sigpanic: panicmem()
/home/andrew/src/go/gitea/modules/convert/pull.go:117 (0x15f8111)
ToAPIPullRequest: log.Error("GetCommit[%s]: %v", headBranch.Name, err)
/home/andrew/src/go/gitea/routers/api/v1/repo/pull.go:167 (0x17bd1f4)
GetPullRequest: ctx.JSON(http.StatusOK, convert.ToAPIPullRequest(pr))
and
2020/03/08 21:33:14 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:199 (0x44c73b)
panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:394 (0x44c578)
sigpanic: panicmem()
/home/andrew/src/go/gitea/modules/convert/pull.go:117 (0x15f8111)
ToAPIPullRequest: log.Error("GetCommit[%s]: %v", headBranch.Name, err)
/home/andrew/src/go/gitea/routers/api/v1/repo/pull.go:112 (0x17bcdc6)
ListPullRequests: apiPrs[i] = convert.ToAPIPullRequest(prs[i])
/usr/local/go/src/reflect/value.go:460 (0x497885)
Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:321 (0x497043)
Value.Call: return v.call("Call", in)
/home/andrew/src/go/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0xfd04e9)
(*injector).callInvoke: return reflect.ValueOf(f).Call(in), nil
/home/andrew/src/go/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0xfcfe99)
(*injector).Invoke: return inj.callInvoke(f, t, t.NumIn())
/home/andrew/src/go/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xfd1488)
(*Context).run: vals, err := c.Invoke(c.handler())
Most helpful comment
Replicated
and