benzelano / test_lh_import

1 stars 0 forks source link

Error in transition_collection.rb #152

Closed benzelano closed 13 years ago

benzelano commented 13 years ago

Thibaud Guillaume-Gentil opened this issue

I randomly got this error when I run all my specs (rails 3 beta4, state_machine git/master, ree 1.8.7):

@@@ You have a nil object when you didn’t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include?

/Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/transition_collection.rb:69:in `perform’

# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/machine.rb:1505:in`create_or_update’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/persistence.rb:36:in `save’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/validations.rb:40:in`save’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/attribute_methods/dirty.rb:21:in `save’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:235:in`save’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:287:in `with_transaction_returning_status’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in`transaction’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:202:in `transaction’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:285:in`with_transaction_returning_status’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:235:in `save’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:246:in`rollback_active_record_state!’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:234:in `save’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/transition_collection.rb:153:in`send’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/transition_collection.rb:153:in `run_actions’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/transition_collection.rb:153:in`each’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/transition_collection.rb:153:in `run_actions’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/transition_collection.rb:169:in`catch_exceptions’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/transition_collection.rb:147:in `run_actions’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/transition_collection.rb:60:in`perform’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/transition.rb:144:in `perform’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/event.rb:192:in`fire’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/event.rb:243:in `add_actions’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/machine.rb:537:in`call’
# /Users/Thibaud/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-master/lib/state_machine/machine.rb:537:in `unsuspend’

@@@

Any ideas? Thanks for your help!

original LH ticket

This ticket has 0 attachment(s).

benzelano commented 13 years ago

This will be really difficult to debug without reproducing it in an environment that’s not affected by other code / plugins in your application. However, my guess is that something either in your application code or in a plugin/gem being used is overriding the TransitionCollection#reset method.

If you look at the logic, it should theoretically be impossible for this error to occur.

I would start by verifying that #reset isn’t getting overwritten. Other than that, there’s not much I can do without more context. Let me know what you find.

benzelano commented 13 years ago

Thibaud Guillaume-Gentil commented

Ok thanks, I’ll verify if a gem/plugin overwrite this #reset.

benzelano commented 13 years ago

Thibaud Guillaume-Gentil commented

"sadly" none of my gem/plugin do nasty stuff with TransitionCollection.reset. Others ideas? :-/

benzelano commented 13 years ago

Rémy Coutable commented

Hi Aaron, I’m a co-worker of Thibaud and I just got an other error, mentioning the #reset method this time, see below:

You have a nil object when you didn’t expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.clear
    # /Users/remy/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.0.beta4/lib/active_support/ordered_hash.rb:122:in `clear’
    # /Users/remy/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-afe2b2304f9bcfb9fb3069ec287f17796fe93ff7/lib/state_machine/integrations/active_model.rb:283:in `reset’
    # /Users/remy/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-afe2b2304f9bcfb9fb3069ec287f17796fe93ff7/lib/state_machine/event.rb:189:in `fire’
    # /Users/remy/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-afe2b2304f9bcfb9fb3069ec287f17796fe93ff7/lib/state_machine/event.rb:243:in `add_actions’
    # /Users/remy/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-afe2b2304f9bcfb9fb3069ec287f17796fe93ff7/lib/state_machine/machine.rb:537:in `call’
    # /Users/remy/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/state_machine-0f97fce5930a7eaf69552c65d43bd98bf554e321-afe2b2304f9bcfb9fb3069ec287f17796fe93ff7/lib/state_machine/machine.rb:537:in `activate’

I have no more clue for the moment, though... Hope it can helps.

benzelano commented 13 years ago

Thibaud and Rémy -

Is there any chance you guys are doing any sort of object marshaling? These errors are pretty baffling. That particular reset error is coming out of the Rails internals and not state_machine.

As I mentioned, without more context around the actual model implementation / state machine definition, ideally within a sandboxed application, there’s not much more help I can provide.

benzelano commented 13 years ago

Rémy Coutable commented

Hi Aaron,

we’re actually heavily using VCR that stores webmock responses in YAML files. The problem is that we can’t reproduce these errors in a predictable way, it really seems to be "random". Moreover, we don’t think it’s a state-machine related bug, because it occurs also when state-machine is not involved at all.

We have also posted an issue on VCR, since it seems to be the real problem (now that you’ve pointed out the marshaling possible issue): http://github.com/myronmarston/vcr/issues#issue/4

Do you think it could be due to VCR’s intensive webmock objects marshaling to YAML?

Thanks for your help again,

Rémy & Thibaud

benzelano commented 13 years ago

I have a suspicion that it’s very likely related to VCR and whatever object marshaling it does. I’m going to close this ticket for now... if you end up finding something in state_machine that is adding to the problem, feel free to reopen.

benzelano commented 13 years ago

Thibaud Guillaume-Gentil commented

Ok fine, we’re investigate the VCR & Yaml bug. Thanks Aaron.