Skip to content

Commit 47ae544

Browse files
authored
fix(feature-flags): rules should evaluate with an AND op (aws-powertools#724)
1 parent 610f569 commit 47ae544

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

aws_lambda_powertools/utilities/feature_flags/feature_flags.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,9 @@ def _evaluate_rules(
105105
if self._evaluate_conditions(rule_name=rule_name, feature_name=feature_name, rule=rule, context=context):
106106
return bool(rule_match_value)
107107

108-
# no rule matched, return default value of feature
109-
self.logger.debug(
110-
f"no rule matched, returning feature default, default={feat_default}, name={feature_name}"
111-
)
112-
return feat_default
113-
return False
108+
# no rule matched, return default value of feature
109+
self.logger.debug(f"no rule matched, returning feature default, default={feat_default}, name={feature_name}")
110+
return feat_default
114111

115112
def get_configuration(self) -> Dict:
116113
"""Get validated feature flag schema from configured store.

tests/functional/feature_flags/test_feature_flags.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ def test_flags_conditions_no_rule_match_equal_multiple_conditions(mocker, config
233233
# check rule match for multiple of action types
234234
def test_flags_conditions_rule_match_multiple_actions_multiple_rules_multiple_conditions(mocker, config):
235235
expected_value_first_check = True
236-
expected_value_second_check = False
236+
expected_value_second_check = True
237237
expected_value_third_check = False
238-
expected_value_fourth_case = False
238+
expected_value_fourth_check = False
239239
mocked_app_config_schema = {
240240
"my_feature": {
241241
"default": expected_value_third_check,
@@ -295,9 +295,9 @@ def test_flags_conditions_rule_match_multiple_actions_multiple_rules_multiple_co
295295
toggle = feature_flags.evaluate(
296296
name="my_fake_feature",
297297
context={"tenant_id": "11114446", "username": "ab"},
298-
default=expected_value_fourth_case,
298+
default=expected_value_fourth_check,
299299
)
300-
assert toggle == expected_value_fourth_case
300+
assert toggle == expected_value_fourth_check
301301

302302

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

0 commit comments

Comments
 (0)