flipper icon indicating copy to clipboard operation
flipper copied to clipboard

Rails credentials read prevents Flipper from working on Rails < 5.2

Open clinejj opened this issue 1 year ago • 2 comments

In https://github.com/flippercloud/flipper/pull/782, there was an update to read values from Rails credentials. Credentials were added in Rails 5.2, which means this throws an error when using Flipper 1.1.0+ and Rails < 5.2:

2.544 NoMethodError: undefined method `credentials' for #<Website::Application:0x0000ffff8676ff30>
2.544 /website/config/environment.rb:5:in `<top (required)>'
2.544 /usr/local/ruby-2.7.8/bin/bundle:23:in `load'
2.544 /usr/local/ruby-2.7.8/bin/bundle:23:in `<main>'
2.544 Tasks: TOP => environment
2.544 (See full trace by running task with --trace)

There isn't an explicit dependency on particular Rails versions in the gemspec, however flipper-active_record does have a requirement for Rails >= 4.2. Without getting too nitpicky on the solutions here, some possible options:

  • Set a minimum Rails version in order to use Flipper
  • Update the calls at https://github.com/flippercloud/flipper/blob/0e996298dec5f05d4a9feb11369cb7db4e402a09/lib/flipper/engine.rb#L41-L42 to check if the credentials method exists, and if not rely on the env vars

There's also a question of whether those env var checks need to happen there, rather than inside the cloud? block since they seem to only apply to cloud users (this is not used in a cloud application FWIW).

clinejj avatar Mar 06 '24 21:03 clinejj

Generally I’d say we don’t support versions that are EOL by rails but checking if the app responds to credentials seems easy. Any interest in a PR?

jnunemaker avatar Mar 06 '24 21:03 jnunemaker

Sounds good, will submit in the next week-ish

clinejj avatar Mar 07 '24 15:03 clinejj