Feature flags should always be used with a context/actor
TL;DR
Today we allow to use feature flags freely with or without actor (aka context).
To make things consistent, we should always assign context to feature flag and validate it to ensure that we use the same context in many places.
Example:
Feature.enabled?(:my_feature_flag, project)
Using feature flags checks without an actor is sometimes dangerous and can lead to serious production incidents.
Proposal
- Change interface to require usage of
thing
- Introduce a special
thing = :instance
to indicate a deliberate usage of instance-wide feature flags - Validate the context/actor/thing via YAML that the context is used consistently across all usages of
enabled?
Implementation proposal
-
Feature#enabled?(key, thing)
withoutnil
- To indicate instance-wide feature flag we would use
Feature.enabled?(key, :instance)
- YAML definition would receive
thing: instance
,thing: project
,thing: user
to indicate a used context - ChatOps and API could validate if a supported context is being passed when enabling a gate for feature flags.
This makes our usage of feature flags even more consistent and validated.
Feature.enabled?(:my_feature_flag, project)
Feature.enabled?(:my_feature_flag, :instance)
Likely the logic to understand the "thing" would be:
used_thing = thing.flipper_id.split(':', 2).first
The YAML would look like:
thing: instance
thing: [Project] # array initially would allow to support many different things, if this context is ambiguous
Links
Edited by Grzegorz Bizon