dlvhdr / gh-dash

A beautiful CLI dashboard for GitHub 🚀
https://dlvhdr.github.io/gh-dash
MIT License
7.06k stars 208 forks source link

[BUG] runtime error: invalid memory address or nil pointer dereference #264

Closed TomfromBerlin closed 1 year ago

TomfromBerlin commented 1 year ago

Describe the bug I installed gh-dash and ran it. When I tried to do something in an repo, a message appeared which states: "authentication token not found for host github.com". I did gh auth before I installed the extension (btw, it is the only extension I have installed). Then I pressed x to refresh and gh-dash crashed, causing a panic.

Here is the output:

Caught panic:

runtime error: invalid memory address or nil pointer dereference

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /usr/local/Cellar/go/1.20.3/libexec/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /usr/local/Cellar/go/1.20.3/libexec/src/runtime/debug/stack.go:16 +0x19
github.com/charmbracelet/bubbletea.(*Program).Run.func1()
        /Users/dolevh/code/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.23.0/tea.go:385 +0x95
panic({0xd017c0, 0x15573a0})
        /usr/local/Cellar/go/1.20.3/libexec/src/runtime/panic.go:884 +0x213
github.com/dlvhdr/gh-dash/ui/components/prssection.(*Model).close(0xc000328000)
        /Users/dolevh/code/personal/gh-dash/ui/components/prssection/close.go:15 +0xe9
github.com/dlvhdr/gh-dash/ui/components/prssection.Model.Update({{0x1, {{0xc00029ac20, 0x10}, {0xc00033ce88, 0x12}, 0x0}, 0xc000233768, {{{...}, 0x5f5e100}, {0x0, ...}, ...}, ...}, ...}, ...)
        /Users/dolevh/code/personal/gh-dash/ui/components/prssection/prssection.go:83 +0x16e7
github.com/dlvhdr/gh-dash/ui.(*Model).updateSection(0xc000232000, 0x1, {0xd8b159?, 0x1?}, {0xd43380?, 0xc00034c090?})
        /Users/dolevh/code/personal/gh-dash/ui/ui.go:440 +0x82
github.com/dlvhdr/gh-dash/ui.(*Model).updateCurrentSection(0xc000232000, {0xd43380, 0xc00034c090})
        /Users/dolevh/code/personal/gh-dash/ui/ui.go:459 +0xe5
github.com/dlvhdr/gh-dash/ui.Model.Update({{{0x0, 0x0}, {{0xc000389140, 0x2, 0x2}, {{...}, {...}}, 0x0}, {{0xc000389160, 0x2, ...}, ...}, ...}, ...}, ...)
        /Users/dolevh/code/personal/gh-dash/ui/ui.go:349 +0x1bfe
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0xc0009160b0, {0xfff440?, 0xc000310000?}, 0xffc160?)
        /Users/dolevh/code/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.23.0/tea.go:324 +0x60a
github.com/charmbracelet/bubbletea.(*Program).Run(0xc0009160b0)
        /Users/dolevh/code/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.23.0/tea.go:448 +0x91a
github.com/dlvhdr/gh-dash/cmd.init.0.func1(0x1562200?, {0xda4331?, 0x0?, 0x0?})
        /Users/dolevh/code/personal/gh-dash/cmd/root.go:131 +0x255
github.com/spf13/cobra.(*Command).execute(0x1562200, {0xc000022240, 0x0, 0x0})
        /Users/dolevh/code/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0x1562200)
        /Users/dolevh/code/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/dolevh/code/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/dlvhdr/gh-dash/cmd.Execute()
        /Users/dolevh/code/personal/gh-dash/cmd/root.go:41 +0x25
main.main()
        /Users/dolevh/code/personal/gh-dash/gh-dash.go:8 +0x17

run with `gh dash > returning

...
────────────────────────────────────────────────────
 authentication token not found for host github.com
──────────────────────
...

To Reproduce Steps to reproduce the behavior:

  1. cd <repo dir>
  2. gh dash
  3. press x
  4. See error
  5. run gh dash > returning to write output to file
  6. see message

Expected behavior gh-dash should not crash when pressing x

Screenshots

gh-dash.webm

Desktop (please complete the following information):

Name Value
Operating System: Manjaro Linux
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.104.0
Terminal: konsole
Qt Version: 5.15.8
Kernel Version: 6.1.25-1-MANJARO (64-bit)
Graphics Platform: X11
Processors: 64 × AMD Ryzen Threadripper 3970X 32-Core Processor
Memory: 62.6 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 2080 SUPER/PCIe/SSE2
Mainboard Manufacturer: ASUS
dlvhdr commented 1 year ago

Hey, did you build from main or from the latest release? If not from main, can you try and build main and run that?

TomfromBerlin commented 1 year ago

The extension has been installed using gh extension install dlvhdr/gh-dash. I guess, it came from main.

creativecreature commented 1 year ago

I'm seeing the exact same issue. I did a gh extension remove dlvhdr/gh-dash and gh extension install dlvhdr/gh-dash` just now.

TomfromBerlin commented 1 year ago

I did that, too. Same result.

dlvhdr commented 1 year ago

Hmm I'm not able to reproduce. Might be that github recently made a change to their auth. I had a contribution lately that dealt with github's auth, can some try and build from source and tell me if it still reproduces? I can then release a new version.

dlvhdr commented 1 year ago

OK I'm able to reproduce after doing a gh logout and gh login

dlvhdr commented 1 year ago

This is solved with the latest code, so releasing a version.

TomfromBerlin commented 1 year ago

:+1: I will test it. Hope, it'll work.

dlvhdr commented 1 year ago

Just released, let me know

TomfromBerlin commented 1 year ago

Here we go again...

gh-dash.webm

The error msg:

non-200 OK status code: 502 Bad Gateway body: "{\n \"data\": null,\n \"errors\":[\n {\n \"message\":\"Something went wrong while executing your query. This may be the result of a timeout, or it could be a GitHub bug. Please include "C084:E8D3:C5BD6ED:C7DC083:6450215F" when reporting this 

I tried it a few times. Here is another error code, just in case: A7D4:799E:B5B6124:B7DB37C:64502E5B

dlvhdr commented 1 year ago

Hmmm can you try what I did and do a gh logout followed by a gh login?

creativecreature commented 1 year ago

Your fix works for me 👍

TomfromBerlin commented 1 year ago

Okay, I think I have an idea what happened - besides my own incompetence. If you initiate into a reload without anything selected, it causes a panic and gh-dash crashes. I created a pull request in one of my repositories and then started gh-dash in the directory. The pull request showed up and I was able to merge it. Then reopen with <shift>-x also worked. However, when I quit gh-dash, restart it and press <shift>-x again in the same repository, gh-dash crashes. Here it might help to catch such an error beforehand by issuing a message that nothing is selected and therefore reopen is more or less useless and will not be executed. Unfortunately I have no idea if this is possible in go. It's just an idea. What doesn't work either is fetching archived pull requests. This results again in an error message non-200 OK status code: 502 Bad Gateway body: "{\n \"data\": null,\n \"errors\":[\n {\n \"message\":\"Something went wrong while executing your query. This may - as mentioned in the error message (see the previous post of mine) - be a bug in Github. However, it may also be that this is again due to my inability....