flippercloud / flipper

🐬 Beautiful, performant feature flags for Ruby.
https://www.flippercloud.io/docs
MIT License
3.71k stars 414 forks source link

Flipper-active_record breaks in 0.26.2+ with Rails 4.2 #858

Open clinejj opened 8 months ago

clinejj commented 8 months ago

We use Rails 4.2, and after updating from Flipper 0.26.1 to 0.26.2 saw the below error after loading the web UI. The only change was https://github.com/flippercloud/flipper/pull/707, which my guess is the culprit is going from @feature_class.connection.select_all to @feature_class.connection.select_rows.

The flipper-active_record gem has a minimum Rails 4.2 dependency, so would ideally have this patched or a minimum AR version specified.

Stack trace:

TypeError at /admin/flipper
no implicit conversion of Arel::SelectManager into String

ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#translate_exception_class
activerecord (4.2.11.3) lib/active_record/connection_adapters/abstract_adapter.rb, line 473
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#log
activerecord (4.2.11.3) lib/active_record/connection_adapters/abstract_adapter.rb, line 486
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#log
activerecord (4.2.11.3) lib/active_record/connection_adapters/abstract_adapter.rb, line 477
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#exec_no_cache
activerecord (4.2.11.3) lib/active_record/connection_adapters/postgresql_adapter.rb, line 592
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#execute_and_clear
activerecord (4.2.11.3) lib/active_record/connection_adapters/postgresql_adapter.rb, line 584
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#select_rows
activerecord (4.2.11.3) lib/active_record/connection_adapters/postgresql/database_statements.rb, line 70
block in Flipper::Adapters::ActiveRecord#get_all
flipper-active_record (0.26.2) lib/flipper/adapters/active_record.rb, line 127
ActiveRecord::ConnectionAdapters::ConnectionPool#with_connection
activerecord (4.2.11.3) lib/active_record/connection_adapters/abstract/connection_pool.rb, line 292
Flipper::Adapters::ActiveRecord#with_connection
flipper-active_record (0.26.2) lib/flipper/adapters/active_record.rb, line 259
Flipper::Adapters::ActiveRecord#get_all
flipper-active_record (0.26.2) lib/flipper/adapters/active_record.rb, line 120
Flipper::Adapters::Memoizable#get_all
flipper (0.26.2) lib/flipper/adapters/memoizable.rb, line 104
Flipper::DSL#preload_all
flipper (0.26.2) lib/flipper/dsl.rb, line 202
jnunemaker commented 8 months ago

Open to a PR but not sure I could even get 4.2 running again in an ok amount of time. I lowered the dependency version for people in the past who wanted to operate with YMMV on older versions. We try to doc everywhere that we do not support the older versions officially. Maybe I should put a note by the gemspec dep too...

jnunemaker commented 8 months ago

Probably the "fix" is to use select_all for 4.2 else select_rows.