Skip to content

fix(feature-flags): rules should evaluate with an AND op #724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,9 @@ def _evaluate_rules(
if self._evaluate_conditions(rule_name=rule_name, feature_name=feature_name, rule=rule, context=context):
return bool(rule_match_value)

# no rule matched, return default value of feature
self.logger.debug(
f"no rule matched, returning feature default, default={feat_default}, name={feature_name}"
)
return feat_default
return False
# no rule matched, return default value of feature
self.logger.debug(f"no rule matched, returning feature default, default={feat_default}, name={feature_name}")
return feat_default

def get_configuration(self) -> Dict:
"""Get validated feature flag schema from configured store.
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/feature_flags/test_feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ def test_flags_conditions_no_rule_match_equal_multiple_conditions(mocker, config
# check rule match for multiple of action types
def test_flags_conditions_rule_match_multiple_actions_multiple_rules_multiple_conditions(mocker, config):
expected_value_first_check = True
expected_value_second_check = False
expected_value_second_check = True
expected_value_third_check = False
expected_value_fourth_case = False
expected_value_fourth_check = False
mocked_app_config_schema = {
"my_feature": {
"default": expected_value_third_check,
Expand Down Expand Up @@ -295,9 +295,9 @@ def test_flags_conditions_rule_match_multiple_actions_multiple_rules_multiple_co
toggle = feature_flags.evaluate(
name="my_fake_feature",
context={"tenant_id": "11114446", "username": "ab"},
default=expected_value_fourth_case,
default=expected_value_fourth_check,
)
assert toggle == expected_value_fourth_case
assert toggle == expected_value_fourth_check


# check a case where the feature exists but the rule doesn't match so we revert to the default value of the feature
Expand Down