Skip to content

Fix handling of conditional gates and default-enabled feature flags

Stan Hu requested to merge sh-ff-default-enabled-and-cond into master

This commit fixes a surprising behavior that occurred if a conditional gate were defined on a feature flag and default_enabled: true were set in the YAML file.

In gitlab-com/gl-infra/production#4888 (closed), we saw the combined_menu feature flag had been enabled for a subset of users, and the feature flag YAML file had been updated to specify default_enabled: true. However, that did not make the feature flag active for all users; only the users that had this flag explicitly enabled would see it. This occurred because of the way Flipper works: a feature is only enabled if an actor passes a defined gate. Clearing the feature flag enabled the feature for all.

We can simplify the feature flag check by returning true whenever:

  1. default_enabled: true is set in the YAML
  2. The feature flag is conditional on certain actors.

Note that with this change, you can no longer disable a feature for all by activating the flag for a single user or project, but this was never a use case before. https://github.com/jnunemaker/flipper/issues/514 discusses a Flipper feature that would provide a deny rather than an allow list.

We can see which feature flags in production would be affected by this change:

Feature.all.each do |feature|
  if feature.conditional?
     definition = Feature::Definition.get(feature.name)
     if definition&.default_enabled
       puts "#{feature.name} has a mismatch!"
     end
  end
end

It looks like two feature flags would be affected:

  • async_filtering
  • sidebar_refactor
Edited by Stan Hu

Merge request reports