Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `>=' for nil:NilClass in 0.33.0 #964

Closed
roccoblues opened this issue Mar 6, 2020 · 8 comments · Fixed by #966
Closed

NoMethodError: undefined method `>=' for nil:NilClass in 0.33.0 #964

roccoblues opened this issue Mar 6, 2020 · 8 comments · Fixed by #966
Assignees
Labels
bug Involves a bug community Was opened by a community member core Involves Datadog core libraries
Milestone

Comments

@roccoblues
Copy link

Looks like 32f512a broke our deployment. Version 0.32.0 works fine. This is with rails 6.0.2.1 and ruby 2.6.5. Let me know if you need more info.

      01 NoMethodError: undefined method `>=' for nil:NilClass
      01 /home/deploy/apps/twentybn/shared/bundle/ruby/2.6.0/gems/ddtrace-0.33.0/lib/ddtrace/contrib/rails/integration.rb:23:in `compatible?'
      01 /home/deploy/apps/twentybn/shared/bundle/ruby/2.6.0/gems/ddtrace-0.33.0/lib/ddtrace/contrib/patchable.rb:47:in `patch'
      01 /home/deploy/apps/twentybn/shared/bundle/ruby/2.6.0/gems/ddtrace-0.33.0/lib/ddtrace/contrib/extensions.rb:46:in `use'
      01 /home/deploy/apps/twentybn/releases/20200306091807/config/initializers/datadog.rb:17:in `block in <main>'
      01 /home/deploy/apps/twentybn/shared/bundle/ruby/2.6.0/gems/ddtrace-0.33.0/lib/ddtrace/configuration.rb:15:in `configure'
      01 /home/deploy/apps/twentybn/releases/20200306091807/config/initializers/datadog.rb:10:in `<main>'
@brafales
Copy link

brafales commented Mar 6, 2020

Hello,

I've managed to narrow it down to this specific tracer:

c.use :rest_client, split_by_domain: true

If we stop using the rest_client tracer, our deploys work. So something would suggest that the rest_client code is somehow assuming version will return a Rails version but it isn't.

@brafales
Copy link

brafales commented Mar 6, 2020

Turns out we do not have the rest_client gem in our project anymore and forgot to remove the configuration option in DataDog. That's most likely what's causing the issue. However I would expect the client not to blow up but just ignore that configuration option, or throw a warning if the ::RestClient::Request constant is not defined, rather than blowing up.

Hope that helps.

@javierjulio
Copy link

We are running into the same error, but with AWS. In our DataDog config we do have c.use :aws along with other services.

NoMethodError: undefined method `>=' for nil:NilClass
/usr/local/bundle/gems/ddtrace-0.33.0/lib/ddtrace/contrib/aws/integration.rb:27:in `compatible?'
/usr/local/bundle/gems/ddtrace-0.33.0/lib/ddtrace/contrib/patchable.rb:47:in `patch'
/usr/local/bundle/gems/ddtrace-0.33.0/lib/ddtrace/contrib/extensions.rb:46:in `use'
/deploy/config/initializers/datadog.rb:14:in `block in <top (required)>'
/usr/local/bundle/gems/ddtrace-0.33.0/lib/ddtrace/configuration.rb:15:in `configure'
/deploy/config/initializers/datadog.rb:5:in `<top (required)>'
/usr/local/bundle/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:319:in `load'
/usr/local/bundle/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:319:in `block in load'
/usr/local/bundle/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:319:in `load'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:667:in `block in load_config_initializer'
/usr/local/bundle/gems/activesupport-6.0.2.1/lib/active_support/notifications.rb:182:in `instrument'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:666:in `load_config_initializer'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:624:in `block (2 levels) in <class:Engine>'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:623:in `each'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:623:in `block in <class:Engine>'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `run'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:50:in `each'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:50:in `tsort_each_child'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/application.rb:363:in `initialize!'
/deploy/config/environment.rb:5:in `<top (required)>'
/usr/local/bundle/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
/usr/local/bundle/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
/usr/local/bundle/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
/usr/local/bundle/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/application.rb:339:in `require_environment!'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/application.rb:515:in `block in run_tasks_blocks'
/usr/local/bundle/gems/bugsnag-6.13.0/lib/bugsnag/integrations/rake.rb:19:in `execute'
/usr/local/bundle/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
/usr/local/bundle/gems/bugsnag-6.13.0/lib/bugsnag/integrations/rake.rb:19:in `execute'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/command.rb:48:in `invoke'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'

@delner
Copy link
Contributor

delner commented Mar 6, 2020

The common thread between both of these errors is that the version is likely resolving to nil:

class Integration
  include Contrib::Integration
  register_as :rest_client

  def self.version
    Gem.loaded_specs['rest-client'] && Gem.loaded_specs['rest-client'].version
  end

  # ...

  def self.compatible?
    super && version >= Gem::Version.new('1.8')
  end
end

I suspect version is nil because the gems aren't loaded when use is invoked. Are these gems actually loaded and available?

Either way, even if you activated an integration that wasn't available, it shouldn't raise an error like this... something we'll address.

@delner
Copy link
Contributor

delner commented Mar 6, 2020

I'm working on a fix for this, and adding additional unit test coverage to prevent any errors like this again. My current expectation is to have a patch for this released early next week.

@delner
Copy link
Contributor

delner commented Mar 8, 2020

Okay made a PR which I think should fix the problem: #966

@roccoblues @brafales @javierjulio can you test out the branch and confirm it fixes the issue for you?

@brafales
Copy link

brafales commented Mar 9, 2020

Okay made a PR which I think should fix the problem: #966

@roccoblues @brafales @javierjulio can you test out the branch and confirm it fixes the issue for you?

Hi. Thanks for fixing so quickly. It does fix it for rest_client integration.

@delner
Copy link
Contributor

delner commented Mar 9, 2020

Okay, great, we'll try to get a bugfix released soon. Thanks for helping figure this one out!

@delner delner added this to the 0.33.1 milestone Mar 30, 2020
@delner delner added bug Involves a bug community Was opened by a community member core Involves Datadog core libraries labels Mar 30, 2020
@delner delner self-assigned this Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug community Was opened by a community member core Involves Datadog core libraries
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants