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

Possible problem upgrading 2.2.0 -> 2.2.1 #139

Closed
jrmhaig opened this issue May 27, 2015 · 6 comments
Closed

Possible problem upgrading 2.2.0 -> 2.2.1 #139

jrmhaig opened this issue May 27, 2015 · 6 comments

Comments

@jrmhaig
Copy link

jrmhaig commented May 27, 2015

We are still investigating this problem but we started getting errors recently and the only change has been representable gem upgrading from 2.2.0 to 2.2.1.

undefined method `<<' for nil:NilClass (NoMethodError)
/home/devicehive/.rvm/gems/ruby-1.9.3-p448@hive-daemons/gems/virtus-1.0.5/lib/virtus/extensions.rb:65:in `attribute'
/home/devicehive/.rvm/gems/ruby-1.9.3-p448@hive-daemons/gems/virtus-1.0.5/lib/virtus/builder/hook_context.rb:44:in `block in initialize_attribute_method'
/home/devicehive/.rvm/gems/ruby-1.9.3-p448@hive-daemons/gems/hive-messages-1.0.0/lib/hive/messages/job.rb:8:in `<class:Job>'
(etc)

Representable isn't explicitly mentioned in the stack trace but 'hive-messages', one of our own gems, uses roar, which in turn uses representable, and the problem goes away when we fix the version of representable to 2.2.0.

We are still not clear where the problem lies but I thought it would be useful to raise here in case anyone else is seeing anything similar.

@apotonick
Copy link
Member

Can you please paste a representer that uses coercion?

@apotonick
Copy link
Member

@jrmhaig I looked into that. I'm guessing you use virus coercion manually in Job? I have no idea why that is a problem with Representable 2.2.1, though.

Can you make sure you're not using coercion in a representer (the :type option) and if you do, paste a sample representer here?

@jrmhaig
Copy link
Author

jrmhaig commented May 27, 2015

We are in the process of open sourcing things so, although it is fairly useless by itself, I am able to make our hive-messages repository public so you can see how what the Job class looks like:

@jrmhaig
Copy link
Author

jrmhaig commented May 27, 2015

I have reduced this to what I believe is a minimal test that works with 2.2.0 and fails with 2.2.1.

require 'rubygems'
#gem 'representable', '=2.2.0'
gem 'representable', '=2.2.1'
gem 'virtus'
gem 'roar'

require 'virtus'
require 'roar/json'
require 'roar/client'

module Representers
  module JobRepresenter
    include Roar::JSON

    property :command
  end
end

module Messages
  class Base
    include Virtus.model
    include Roar::JSON
    include Roar::Client
  end
end

module Messages
  class Job < Messages::Base
    include Representers::JobRepresenter

    attribute :command, String
  end
end

@jrmhaig
Copy link
Author

jrmhaig commented May 27, 2015

I have further reduced it to:

require 'rubygems'
#gem 'representable', '=2.2.0'
gem 'representable', '=2.2.1'
gem 'virtus'

require 'virtus'
require 'representable/json'

class Base
  include Virtus.model
  include Representable
end

class Job < Base
  property :command
  attribute :command, String
end

Interestingly, this works:

require 'rubygems'
#gem 'representable', '=2.2.0'
gem 'representable', '=2.2.1'
gem 'virtus'

require 'virtus'
require 'representable/json'

class Job
  include Virtus.model
  include Representable
  property :command
  attribute :command, String
end

so it looks like it is to do with the class inheritance.

@apotonick
Copy link
Member

I found the bug, I am a stupid idiot, please laugh at me: v2.2.0...v2.2.1#diff-de25bf89e18d9382cf8e24d22abce389R92

When "cleaning up" the ::inherited method I somehow deleted the super call. Thanks to your excellent bug report, @jrmhaig it took me only minutes to spot the issue. Thanks.

Releasing 2.2.2 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants