Google-cloud-ruby: BigQuery: NoMethodError (undefined method `each' for nil:NilClass)

Created on 16 Mar 2021  路  4Comments  路  Source: googleapis/google-cloud-ruby

Environment details

  • OS: Ubuntu 18.04
  • Ruby version: 2.7.2p137
  • Gem name and version: google-cloud-bigquery (1.29.0)

Steps to reproduce

  1. Set BIGQUERY_PROJECT and BIGQUERY_CREDENTIALS environment variables (I'm setting BIGQUERY_CREDENTIALS to the contents of my JSON credentials file)
  2. Run the code example below

Code example

require 'google/cloud/bigquery'
bigquery = Google::Cloud::Bigquery.new
bigquery.query('SELECT 1')

(same error w/ any SQL I provide)

Full backtrace

irb(main):001:0> require 'google/cloud/bigquery'
=> true
irb(main):002:0> bigquery = Google::Cloud::Bigquery.new
=> #<Google::Cloud::Bigquery::Project:0x000055b076251234 @service=Google::Cloud::Bigquery::Service(<project name>)>
irb(main):003:0> bigquery.query('SELECT 1')
Traceback (most recent call last):
       16: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/serializer.rb:44:in `block in <module:Representable>'
       15: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/hash.rb:34:in `to_hash'
       14: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:45:in `create_representation_with'
       13: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:70:in `representable_map!'
       12: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:51:in `call'
       11: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:51:in `each'
       10: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:53:in `block in call'
        9: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/binding.rb:32:in `compile_fragment'
        8: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:9:in `call'
        7: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:9:in `inject'
        6: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:9:in `each'
        5: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:10:in `block in call'
        4: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:18:in `evaluate'
        3: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:47:in `call'
        2: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:47:in `tap'
        1: from /home/scott/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:48:in `block in call'
NoMethodError (undefined method `each' for nil:NilClass)
irb(main):004:0> 

I believe I'm authenticated b/c I can run bigquery.datasets.count and I get back the correct number

bigquery p0 bug

Most helpful comment

Ok traced it to a regression in declarative-option 0.1.1, someone beat me to the issue report here: https://github.com/apotonick/declarative-option/issues/6

Locking it in your Gemfile should solve the issue for now:

gem "declarative-option", "0.1.0"

Some elaboration: This gem transitively depends on representable, which directly depends on declarative-option. The former has only had one release back in 2017, and after being updated from 0.1.0 to 0.1.1 today, appears to have introduced some sort of regression.

https://github.com/apotonick/declarative-option/issues/6 is the issue open for the regression in declarative-option

https://github.com/trailblazer/representable/issues/241 is the issue open in the representable repo

All 4 comments

I'm running into the same exception but when uploading to a google cloud storage bucket. Some low-level dependency broke. Investigating now.

Ok traced it to a regression in declarative-option 0.1.1, someone beat me to the issue report here: https://github.com/apotonick/declarative-option/issues/6

Locking it in your Gemfile should solve the issue for now:

gem "declarative-option", "0.1.0"

Some elaboration: This gem transitively depends on representable, which directly depends on declarative-option. The former has only had one release back in 2017, and after being updated from 0.1.0 to 0.1.1 today, appears to have introduced some sort of regression.

https://github.com/apotonick/declarative-option/issues/6 is the issue open for the regression in declarative-option

https://github.com/trailblazer/representable/issues/241 is the issue open in the representable repo

declarative-option 0.1.1 was yanked, so clean installs (and reinstalls after uninstalling declarative-option 0.1.1) should no longer have this issue.

@taylorthurlow Thanks for tracking down the source of this! Much appreciated.

Was this page helpful?
0 / 5 - 0 ratings