[GH-ISSUE #17] pulls panic if there is no open pull requests #12

Closed
opened 2026-02-16 12:57:47 -05:00 by yindo · 6 comments
Owner

Originally created by @quantonganh on GitHub (Apr 19, 2019).
Original GitHub issue: https://github.com/go-gitea/tea/issues/17

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x14ece93]

goroutine 1 [running]:
code.gitea.io/tea/cmd.runPulls(0xc000106f20, 0xc0001e2000, 0xc000106f20)
	/Users/quanta/go/src/code.gitea.io/tea/cmd/pulls.go:52 +0x363
github.com/urfave/cli.HandleAction(0x155c680, 0x163e5f8, 0xc000106f20, 0x0, 0xc000086ba0)
	/Users/quanta/go/src/github.com/urfave/cli/app.go:502 +0xbe
github.com/urfave/cli.Command.Run(0x161dc87, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x162e67d, 0x24, 0x0, ...)
	/Users/quanta/go/src/github.com/urfave/cli/command.go:165 +0x420
github.com/urfave/cli.(*App).Run(0xc0001c2380, 0xc0000b6000, 0x4, 0x4, 0x0, 0x0)
	/Users/quanta/go/src/github.com/urfave/cli/app.go:259 +0x6cf
main.main()
	/Users/quanta/go/src/code.gitea.io/tea/main.go:43 +0x264

The reason is: https://github.com/go-gitea/go-sdk/issues/161

Originally created by @quantonganh on GitHub (Apr 19, 2019). Original GitHub issue: https://github.com/go-gitea/tea/issues/17 ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x14ece93] goroutine 1 [running]: code.gitea.io/tea/cmd.runPulls(0xc000106f20, 0xc0001e2000, 0xc000106f20) /Users/quanta/go/src/code.gitea.io/tea/cmd/pulls.go:52 +0x363 github.com/urfave/cli.HandleAction(0x155c680, 0x163e5f8, 0xc000106f20, 0x0, 0xc000086ba0) /Users/quanta/go/src/github.com/urfave/cli/app.go:502 +0xbe github.com/urfave/cli.Command.Run(0x161dc87, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x162e67d, 0x24, 0x0, ...) /Users/quanta/go/src/github.com/urfave/cli/command.go:165 +0x420 github.com/urfave/cli.(*App).Run(0xc0001c2380, 0xc0000b6000, 0x4, 0x4, 0x0, 0x0) /Users/quanta/go/src/github.com/urfave/cli/app.go:259 +0x6cf main.main() /Users/quanta/go/src/code.gitea.io/tea/main.go:43 +0x264 ``` The reason is: https://github.com/go-gitea/go-sdk/issues/161
yindo added the bug label 2026-02-16 12:57:47 -05:00
yindo closed this issue 2026-02-16 12:57:48 -05:00
Author
Owner

@lunny commented on GitHub (Apr 19, 2019):

Cannot reproduce here.

➜  log git:(master) pwd
/Users/lunny/gopath/src/gitea.com/lunny/log
➜  log git:(master) tea pulls
No pull requests left
➜  log git:(master) tea login
Name	URL	SSHHost
try	https://try.gitea.io	try.gitea.io
gitea	https://gitea.com	gitea.com
@lunny commented on GitHub (Apr 19, 2019): Cannot reproduce here. ``` ➜ log git:(master) pwd /Users/lunny/gopath/src/gitea.com/lunny/log ➜ log git:(master) tea pulls No pull requests left ➜ log git:(master) tea login Name URL SSHHost try https://try.gitea.io try.gitea.io gitea https://gitea.com gitea.com ```
Author
Owner

@quantonganh commented on GitHub (Apr 19, 2019):

Look at the error, it happened at this line: https://github.com/go-gitea/tea/blob/fb52920af9254e5746997c57745fc11b804106da/cmd/pulls.go#L52

The main problem is ListPullRequestsOptions does not work. Instead of just list open pull requests, it list all.

In your repo, just

  • create a PR
  • merged
  • tea pulls

to see it show all closed/merged PRs.

@quantonganh commented on GitHub (Apr 19, 2019): Look at the error, it happened at this line: https://github.com/go-gitea/tea/blob/fb52920af9254e5746997c57745fc11b804106da/cmd/pulls.go#L52 The main problem is `ListPullRequestsOptions` does not work. Instead of just list open pull requests, it list all. In your repo, just - create a PR - merged - `tea pulls` to see it show all closed/merged PRs.
Author
Owner

@root360-AndreasUlm commented on GitHub (Apr 21, 2019):

I can reproduce this behaviour.

Printing the resulting addresses of ListRepoPullRequests when the error happens you get:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x8f9aea]
...

The access to the 3rd element then raises the panic.

After adding a 'nil'-check the panic is not raised:

diff --git a/cmd/pulls.go b/cmd/pulls.go
index 7fe7d8b..43e6245 100644
--- a/cmd/pulls.go
+++ b/cmd/pulls.go
@@ -49,6 +49,9 @@ func runPulls(ctx *cli.Context) error {
        }
 
        for _, pr := range prs {
+               if pr == nil {
+                       continue
+               }
                name := pr.Poster.FullName
                if len(name) == 0 {
                        name = pr.Poster.UserName
@root360-AndreasUlm commented on GitHub (Apr 21, 2019): I can reproduce this behaviour. Printing the resulting addresses of ListRepoPullRequests when the error happens you get: ```[0xc00016a140 0xc00016a3c0 <nil> <nil> <nil> 0xc00016a500 0xc00016a640 0xc00016a780 0xc00016a8c0 0xc00016aa00 0xc00016ab40 0xc00016ac80 0xc00016adc0 0xc00016af00 0xc00016b540 0xc00016b680 0xc00016b7c0 0xc00016b900 0xc00016ba40 0xc00016bb80 0xc00016bcc0 0xc00016be00 0xc000426000 0xc000426140 0xc000426280 0xc0004263c0 0xc000426500 0xc000426640 0xc000426780 0xc0004268c0 0xc000426a00 0xc000426b40 0xc000426c80 0xc000426dc0 0xc000426f00 0xc000427040 0xc000427180 0xc0004272c0 0xc000427400 0xc000427540] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x8f9aea] ... ``` The access to the 3rd element then raises the panic. After adding a 'nil'-check the panic is not raised: ``` diff --git a/cmd/pulls.go b/cmd/pulls.go index 7fe7d8b..43e6245 100644 --- a/cmd/pulls.go +++ b/cmd/pulls.go @@ -49,6 +49,9 @@ func runPulls(ctx *cli.Context) error { } for _, pr := range prs { + if pr == nil { + continue + } name := pr.Poster.FullName if len(name) == 0 { name = pr.Poster.UserName ```
Author
Owner

@lunny commented on GitHub (Apr 22, 2019):

@root360-AndreasUlm could you send a PR to fix that?

@lunny commented on GitHub (Apr 22, 2019): @root360-AndreasUlm could you send a PR to fix that?
Author
Owner

@root360-AndreasUlm commented on GitHub (Apr 23, 2019):

@lunny I'll send a PR today

@root360-AndreasUlm commented on GitHub (Apr 23, 2019): @lunny I'll send a PR today
Author
Owner

@root360-AndreasUlm commented on GitHub (Apr 23, 2019):

@lunny created PR https://github.com/go-gitea/tea/pull/18

@root360-AndreasUlm commented on GitHub (Apr 23, 2019): @lunny created PR https://github.com/go-gitea/tea/pull/18
yindo changed title from pulls panic if there is no open pull requests to [GH-ISSUE #17] pulls panic if there is no open pull requests 2026-06-05 16:34:07 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: go-gitea/tea#12