You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bin/bundle exec flipper list throws an exception instead of listing gates.
Repro steps:
use ruby 3.2.5
install rails 8.0.1 gem
create an empty rails app
add and install flipper, flipper-active_record, flipper-ui gems
generate models and setup
migrate
attempt to list flipper flags via bin/bundle exec flipper list
Expected
An empty list of flags
Actual
undefined method `column_for_attribute' for Flipper::Gate:Class (NoMethodError) exception in flipper/adapters/active_record.rb:292:in `value_not_text?'
See below terminal commands for detailed repro and stack trace:
flipper-test % rbenv local 3.2.5
flipper-test % gem install rails -v 8.0.1
flipper-test % rails new .
flipper-test % echo 'gem "flipper"' >> Gemfile
flipper-test % echo 'gem "flipper-active_record"' >> Gemfile
flipper-test % echo 'gem "flipper-ui '~1.2"' >> Gemfile
flipper-test % bin/bundle install
flipper-test % bin/rails g flipper:active_record flipper:setup
flipper-test % bin/rake db:migrate
flipper-test % bin/bundle exec flipper list
bundler: failed to load command: flipper (.rbenv/versions/3.2.5/bin/flipper)
.rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-active_record-1.3.4/lib/flipper/adapters/active_record.rb:292:in `value_not_text?': undefined method `column_for_attribute' for Flipper::Gate:Class (NoMethodError)
@gate_class.column_for_attribute(:value).type != :text
^^^^^^^^^^^^^^^^^^^^^
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-active_record-1.3.4/lib/flipper/adapters/active_record.rb:65:in `initialize'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-active_record-1.3.4/lib/flipper/adapters/active_record.rb:306:in `new'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-active_record-1.3.4/lib/flipper/adapters/active_record.rb:306:in `block (2 levels) in <main>'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/lib/flipper/adapter_builder.rb:41:in `to_adapter'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/lib/flipper/configuration.rb:29:in `adapter'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/lib/flipper/engine.rb:55:in `block (3 levels) in <class:Engine>'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/lib/flipper/configuration.rb:65:in `default'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/lib/flipper.rb:46:in `instance'
from .rbenv/versions/3.2.5/lib/ruby/3.2.0/forwardable.rb:234:in `features'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/lib/flipper/cli.rb:76:in `block (2 levels) in initialize'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/lib/flipper/cli.rb:255:in `run'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/lib/flipper/cli.rb:123:in `run'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/lib/flipper/cli.rb:6:in `run'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/flipper-1.3.4/exe/flipper:5:in `<top (required)>'
from .rbenv/versions/3.2.5/bin/flipper:25:in `load'
from .rbenv/versions/3.2.5/bin/flipper:25:in `<top (required)>'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/cli/exec.rb:58:in `load'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/cli/exec.rb:58:in `kernel_load'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/cli/exec.rb:23:in `run'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/cli.rb:455:in `exec'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/cli.rb:35:in `dispatch'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/cli.rb:29:in `start'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/exe/bundle:28:in `block in <top (required)>'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
from .rbenv/versions/3.2.5/lib/ruby/gems/3.2.0/gems/bundler-2.5.17/exe/bundle:20:in `<top (required)>'
from bin/bundle:108:in `load'
from bin/bundle:108:in `<main>'
It also repros with the latest released version of flipper in rails 7 and ruby 3.1:
rbenv local 3.1.6
gem install rails
rails new .
echo 'gem "flipper"' >> Gemfile
echo 'gem "flipper-active_record"' >> Gemfile
echo 'gem "flipper-ui"' >> Gemfile
bin/bundle install
bin/rails g flipper:active_record flipper:setup
bin/rake db:migrate
bin/bundle exec flipper list
produces the same exception.
Going back to flipper 1.3.0 does not. With this in the Gemfile:
This is caused because ActiveRecord::Base isn't actually loaded yet, so the ActiveSupport.on_load(:active_record) callback hasn't happened so none of the active record methods are available to the @gate_class when value_not_text? is called.
From a user perspective, the solution is to do something with activerecord in the initializer to force the load. I added this to my flipper initializer:
Issue
bin/bundle exec flipper list
throws an exception instead of listing gates.Repro steps:
bin/bundle exec flipper list
Expected
An empty list of flags
Actual
undefined method `column_for_attribute' for Flipper::Gate:Class (NoMethodError)
exception inflipper/adapters/active_record.rb:292:in `value_not_text?'
See below terminal commands for detailed repro and stack trace:
It also repros with the latest released version of flipper in rails 7 and ruby 3.1:
produces the same exception.
Going back to flipper 1.3.0 does not. With this in the Gemfile:
bin/bundle exec flipper list
does not throw an exception.The text was updated successfully, but these errors were encountered: