minimul / qbo_api

Ruby JSON-only client for QuickBooks Online API v3. Built on top of the Faraday gem.
MIT License
85 stars 45 forks source link

Can't convert Array to String (Array#to_str gives Array) (TypeError) #121

Closed Greyoxide closed 1 year ago

Greyoxide commented 1 year ago

I'm using rails 7.0.1 and ruby 3.0.2

Assuming I use the following example(token and realm redacted):

QboApi.production = false
qbo_api = QboApi.new(access_token: "qyprd2uvCOdRq8xzoSSiiiiii", realm_id: "12314xxxxxx7")
qbo_api.get :customer, 1

I get the following error:

/Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:663:in `to_s': can't convert Array to String (Array#to_str gives Array) (TypeError)

To test the array.to_s method I was able to run the following in the next line: ['test', 'array', 'goes', 'here'].to_s which executed as expected.

I'm only getting this error when I try to use the qbo_api gem, I've never seen this error otherwise. I'm able to get a token from Quickbooks Oauth api, and I'm able to create a session, but when I try to interact with any datasets I get this error.

Here's the full output of the error

/Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:663:in `to_s': can't convert Array to String (Array#to_str gives Array) (TypeError)
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:663:in `message'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:663:in `full_message'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:663:in `handle_exception'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:607:in `block (2 levels) in eval_input'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:777:in `signal_status'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:567:in `block in eval_input'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb/ruby-lex.rb:267:in `block (2 levels) in each_top_level_statement'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb/ruby-lex.rb:249:in `loop'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb/ruby-lex.rb:249:in `block in each_top_level_statement'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb/ruby-lex.rb:248:in `catch'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb/ruby-lex.rb:248:in `each_top_level_statement'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:566:in `eval_input'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:500:in `block in run'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:499:in `catch'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:499:in `run'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.6.2/lib/irb.rb:421:in `start'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/railties-7.0.4/lib/rails/commands/console/console_command.rb:70:in `start'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/railties-7.0.4/lib/rails/commands/console/console_command.rb:19:in `start'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/railties-7.0.4/lib/rails/commands/console/console_command.rb:102:in `perform'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/railties-7.0.4/lib/rails/command/base.rb:87:in `perform'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/railties-7.0.4/lib/rails/command.rb:48:in `invoke'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<main>'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /Users/user_name/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
mculp commented 1 year ago

Is this on 3.0.1? Can you perhaps put this in an app or script so there's a relevant backtrace? I'm only seeing unrelated lines

Greyoxide commented 1 year ago

Testing to see if there's an issue with another gem and I discovered that the nice_hash gem was causing this undesired behavior. by commenting it out I was able to read the error message returned by the QB api. Where previously I was getting the above error.

Since this behavior seems to be with the nice_hash gem, I'm inclined to call this issue closed.

minimul commented 1 year ago

@Greyoxide No problem. Glad you found the issue.