Giter Club home page Giter Club logo

Comments (9)

dannyy83 avatar dannyy83 commented on June 14, 2024 1

Hi @bkeepers, I agree there's not much we can do for flipper to work around this issue. I don't have any suggestions.

For others that may see this problem, I worked around this issue by setting require: false in the Gemfile for json_expressions:

group :test do
  gem 'json_expressions', require: false
end

And instead manually load it in the rails_helper.rb AFTER rails is loaded:

require 'json_expressions/rspec'

from flipper.

bkeepers avatar bkeepers commented on June 14, 2024

Hi @dannyy83, you're actually running into an issue with the strict adapter, introduced in #763. I'm guessing you're running Flipper 1.1? In 1.2 we disabled the strict adapter in tests because people were running into this issue. So you can either upgrade to 1.2 or manually disable it per the directions in the 1.1 release notes (see https://github.com/flippercloud/flipper/releases).

Let me know if that doesn't fix it for you.

from flipper.

dannyy83 avatar dannyy83 commented on June 14, 2024

Hi @bkeepers, I'm seeing this with the following environment:
flipper v1.2.2
flipper-redis v1.2.2
rails v7.1.3
rspec v3.13.0
ruby v3.3.0

My configuration for flipper is:

require 'flipper'
require 'flipper/adapters/redis'

Flipper.configure do |config|
  config.default do
    client = Redis.new(url: 'some_url')
    adapter = Flipper::Adapters::Redis.new(client)
    Flipper.new(adapter)
  end
end

I have no explicit flipper configuration in rspec, except for what's being automatically pulled in from https://github.com/flippercloud/flipper/blob/main/lib/flipper/test_help.rb

from flipper.

dannyy83 avatar dannyy83 commented on June 14, 2024

@bkeepers I've also tried to configure flipper as follows (as here https://www.flippercloud.io/docs/adapters/redis)

require 'flipper/adapters/redis'

And I still have the same issue.

from flipper.

dannyy83 avatar dannyy83 commented on June 14, 2024

I've also tried to disable the strict adapter as suggested:

Rails.application.configure do
  config.flipper.strict = false
end

And this has no effect.

from flipper.

dannyy83 avatar dannyy83 commented on June 14, 2024

Also, here is the stack trace of the error being raised:

     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/adapters/strict.rb:44:in `assert_feature_exists'
     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/adapters/strict.rb:24:in `get'
     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/adapters/memoizable.rb:58:in `get'
     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/feature.rb:279:in `gate_values'
     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/feature.rb:110:in `block in enabled?'
     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/feature.rb:436:in `block in instrument'
     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/instrumenters/noop.rb:5:in `instrument'
     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/feature.rb:433:in `instrument'
     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/feature.rb:107:in `enabled?'
     # /usr/local/bundle/gems/flipper-1.2.2/lib/flipper/dsl.rb:36:in `enabled?'

from flipper.

dannyy83 avatar dannyy83 commented on June 14, 2024

Hi @bkeepers. I've done some more investigation on this, and tracked down the root cause of this problem to https://github.com/flippercloud/flipper/blob/main/lib/flipper/engine.rb#L71

I'm not sure why, but the call to flipper.strict returns the ActiveSupport::OrderedOptions instance, instead of the value of the :strict key (which is false). So, the Strict adapter is being used.

To be more explicit, If I set a breakpoint on the above line, you can see:

> flipper.strict
=> {:env_key=>"flipper", :memoize=>true, :preload=>true, :instrumenter=>ActiveSupport::Notifications, :log=>true, :cloud_path=>"_flipper", :strict=>false, :test_help=>true}

> flipper.strict.class
=> ActiveSupport::OrderedOptions

# But, interestingly
> flipper.dig(:strict)
=> false

from flipper.

dannyy83 avatar dannyy83 commented on June 14, 2024

I've finally tracked down this problem...
In our test env, we also use the json_expressions gem (https://github.com/chancancode/json_expressions).
This gem adds a strict method to Hash and Array which returns a clone and unfortunately this method is called when flipper is initializing in our test env, which is truthy, causing strict mode to be enabled.

from flipper.

bkeepers avatar bkeepers commented on June 14, 2024

@dannyy83 wow, that's a fun one. I'm glad you figured it out! I'm not sure there's much we can do in flipper to work around that, but I'm open to suggestions if you have ideas.

from flipper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.