mrusme / neonmodem

Neon Modem Overdrive
https://neonmodem.com
GNU General Public License v3.0
582 stars 22 forks source link

[Hackernews][Bug] Unable to add Hackernews in HEAD #25

Closed tedwardd closed 1 year ago

tedwardd commented 1 year ago
$ ./neonmodem connect --type hackernews
panic: interface conversion: interface {} is nil, not string
[...]

system/hackernews/hackernews.goL#106 does not work as intended. I've spent some time trying to identify the issue but unfortunately my knowledge of go interfaces is limited so I was unable to determine what the actual values of sys.config were or where those values were coming from. It behaves as though it's not reading in what is expected and is empty which causes the type assertion to fail.

To confirm this, I applied the following changes to system/hackernews/hackernews.go which confirms that sys.config["proxy"] is indeed nil.

diff --git a/system/hackernews/hackernews.go b/system/hackernews/hackernews.go
index cf7068e..d80a4d3 100644
--- a/system/hackernews/hackernews.go
+++ b/system/hackernews/hackernews.go
@@ -103,7 +103,13 @@ func (sys *System) Load() error {
        var httpTransport *http.Transport = http.DefaultTransport.(*http.Transport).
                Clone()

-       proxy := sys.config["proxy"].(string)
+       var proxy string
+
+       if sys.config["proxy"] != nil {
+               proxy = sys.config["proxy"].(string)
+       } else {
+               proxy = ""
+       }
        if proxy != "" {
                proxyURL, err := url.Parse(proxy)
                if err != nil {
mrusme commented 1 year ago

Fix ongoing in https://github.com/mrusme/neonmodem/pull/26

tedwardd commented 1 year ago

Fixed in #26