Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.

pulls panic if there is no open pull requests #17

Closed
quantonganh opened this issue Apr 19, 2019 · 6 comments
Closed

pulls panic if there is no open pull requests #17

quantonganh opened this issue Apr 19, 2019 · 6 comments
Labels
bug Something isn't working

Comments

@quantonganh
Copy link

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: go-gitea/go-sdk#161

@lunny
Copy link
Member

lunny commented 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

@quantonganh
Copy link
Author

Look at the error, it happened at this line:

name := pr.Poster.FullName

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.

@root360-AndreasUlm
Copy link
Contributor

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

@lunny lunny added the bug Something isn't working label Apr 22, 2019
@lunny
Copy link
Member

lunny commented Apr 22, 2019

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

@root360-AndreasUlm
Copy link
Contributor

@lunny I'll send a PR today

root360-AndreasUlm added a commit to root360-AndreasUlm/tea that referenced this issue Apr 23, 2019
@root360-AndreasUlm
Copy link
Contributor

@lunny created PR #18

lafriks pushed a commit that referenced this issue Apr 23, 2019
@lafriks lafriks closed this as completed Apr 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants