twitter / twurl

OAuth-enabled curl for the Twitter API

Home Page:https://developer.twitter.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash with `alias_from_name': undefined method `[]' for nil:NilClass (NoMethodError)

jurijsk opened this issue · comments

Running twurl /1.1/statuses/home_timeline.json after successful authentication leads to:

$ twurl /1.1/statuses/home_timeline.json
Traceback (most recent call last):
        10: from C:/Ruby26-x64/bin/twurl:23:in `<main>'
         9: from C:/Ruby26-x64/bin/twurl:23:in `load'
         8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/bin/twurl:4:in `<top (required)>'
         7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/cli.rb:21:in `run'
         6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/cli.rb:40:in `dispatch'
         5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/abstract_command_controller.rb:7:in `dispatch'
         4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/request_controller.rb:13:in `dispatch'
         3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/rcfile.rb:89:in `alias_from_options'
         2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/rcfile.rb:89:in `each'
         1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/rcfile.rb:90:in `block in alias_from_options'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/twurl-0.9.5/lib/twurl/rcfile.rb:97:in `alias_from_name': undefined method `[]' for nil:NilClass (NoMethodError)

Unable to reproduce this on Mac - it looks like this is falling over reading the .twurlrc file. Can you find one after authentication succeeds? Does twurl accounts work?

Hi @andypiper!
Yes found .twurlrc under c:\users\{username} and it looks like it contains what looks like keys and secrets. twurl accounts also works.

Also trier to use twurl in PowerShell instead of bash and everything works perfectly. So I guess it is environment configuration. Just strange that I have installed everything using bash and it does not work there at the end.

Great to hear you're up-and-running - super strange issue. I'll leave this open in case anyone is able to do a bit more digging on Windows with bash at some point.

While the actual reason behind this error remains unknown it's not great to return backtrace in such a way, so I've fixed the code to not return the backtrace at least.

E.g.,

$ twurl -
Invalid URI detected

*This command returns backtrace in the latest version.

@jkovzels Out of curiosity, is that still reproducible if you put the URL inside the single/double quotes?

$ twurl "/1.1/statuses/home_timeline.json"

looking at your backtrace, it's hitting alias_from_name meaning we were likely unable to parse your arguments (or, it didn't match regex) somehow and tried to find aliases as a fallback, and got this error because you had no aliases configured. Wondering if that's some kind of encoding issue or not, but I can't verify that either. Did you run that command on WSL 2 terminal?

Close until further reports come in.