DmitryTsepelev / store_model

Work with JSON-backed attributes as ActiveRecord-ish models
MIT License
1.04k stars 85 forks source link

NameError: uninitialized constant StoreModel::Types::ArrayType #130

Closed alkesh26 closed 1 year ago

alkesh26 commented 1 year ago

We recently upgraded our application from Rails 5.2.8 to the 6.1.7 version. We are using the 3.1.2 Ruby version and the 1.2.0 version of the StoreModel gem.

We sometimes face the below error on our production servers (triggered randomly).

uninitialized constant StoreModel::Types::ArrayType

            candidate = constant.const_get(name)
                                ^^^^^^^^^^

A stack trace of the above error is as below:

ArgumentError: undefined class/module StoreModel::Types::ArrayType
  from <internal:marshal>:34:in `load'
  from activesupport (6.1.7) lib/active_support/core_ext/marshal.rb:8:in `load'
  from activerecord-session_store (2.0.0) lib/active_record/session_store.rb:54:in `load'
  from activerecord-session_store (2.0.0) lib/active_record/session_store.rb:19:in `deserialize'
  from activerecord-session_store (2.0.0) lib/active_record/session_store/session.rb:64:in `data'
  from activerecord-session_store (2.0.0) lib/action_dispatch/session/active_record_store.rb:148:in `find_session'
  from rack (2.2.4) lib/rack/session/abstract/id.rb:314:in `load_session'
  from actionpack (6.1.7) lib/action_dispatch/middleware/session/abstract_store.rb:45:in `block in load_session'
  from actionpack (6.1.7) lib/action_dispatch/middleware/session/abstract_store.rb:53:in `stale_session_check!'
  from actionpack (6.1.7) lib/action_dispatch/middleware/session/abstract_store.rb:45:in `load_session'
  from actionpack (6.1.7) lib/action_dispatch/request/session.rb:234:in `load!'
  from actionpack (6.1.7) lib/action_dispatch/request/session.rb:226:in `load_for_read!'
  from actionpack (6.1.7) lib/action_dispatch/request/session.rb:92:in `[]'
  from turbolinks (5.2.1) lib/turbolinks/redirection.rb:44:in `set_turbolinks_location_header_from_session'
  from activesupport (6.1.7) lib/active_support/callbacks.rb:427:in `block in make_lambda'

StoreModel::Types::ArrayType was a class present under lib/store_model/types/ directory till 0.7.0 version. The error should not appear in the latest version. Let me know if I missed any steps when we upgraded our Rails app.

DmitryTsepelev commented 1 year ago

Hello, please use Many instead of ArrayType, the behavior should be pretty much the same (https://github.com/DmitryTsepelev/store_model/commit/d65f45d57a5d5e5f43305b974d4a0c86c745ec7d#diff-616e8eaf5922e04790111e623d778a38a79f26f344a0953fb498439017a232f4R9)

alkesh26 commented 1 year ago

Hey @DmitryTsepelev, Thanks for the quick response. Apologies, I forgot to mention one crucial part.

We are not including StoreModel::Types::ArrayType anywhere in our code base. Hence figuring out the issue is a bit tricky.

alkesh26 commented 1 year ago

@DmitryTsepelev, any updates on the above concern?

We are not including StoreModel::Types::ArrayType anywhere in our code base. Hence figuring out the issue is a bit tricky.