Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions optimizely/decision_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def get_variation_for_feature(
- 'error': Boolean indicating if an error occurred during the decision process.
- 'reasons': List of log messages representing decision making for the feature.
"""
holdouts = project_config.get_holdouts_for_flag(feature.key)
holdouts = project_config.get_holdouts_for_flag(feature.id)

if holdouts:
# Has holdouts - use get_decision_for_flag which checks holdouts first
Expand Down Expand Up @@ -708,7 +708,7 @@ def get_decision_for_flag(
user_id = user_context.user_id

# Check holdouts
holdouts = project_config.get_holdouts_for_flag(feature_flag.key)
holdouts = project_config.get_holdouts_for_flag(feature_flag.id)
for holdout in holdouts:
holdout_decision = self.get_variation_for_holdout(holdout, user_context, project_config)
reasons.extend(holdout_decision['reasons'])
Expand Down
2 changes: 1 addition & 1 deletion optimizely/optimizely.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def _get_feature_variable_for_type(
f'Returning default value for variable "{variable_key}" of feature flag "{feature_key}".'
)

if decision.source == enums.DecisionSources.FEATURE_TEST:
if decision.source in (enums.DecisionSources.FEATURE_TEST, enums.DecisionSources.HOLDOUT):
source_info = {
'experiment_key': decision.experiment.key if decision.experiment else None,
'variation_key': self._get_variation_key(decision.variation),
Expand Down
6 changes: 3 additions & 3 deletions optimizely/project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,19 +834,19 @@ def get_flag_variation(

return None

def get_holdouts_for_flag(self, flag_key: str) -> list[HoldoutDict]:
def get_holdouts_for_flag(self, flag_id: str) -> list[HoldoutDict]:
""" Helper method to get holdouts from an applied feature flag.

Args:
flag_key: Key of the feature flag.
flag_id: (REQUIRED) ID of the feature flag.

Returns:
The holdouts that apply for a specific flag.
"""
if not self.holdouts:
return []

return self.flag_holdouts_map.get(flag_key, [])
return self.flag_holdouts_map.get(flag_id, [])

def get_holdout(self, holdout_id: str) -> Optional[HoldoutDict]:
""" Helper method to get holdout from holdout ID.
Expand Down
Loading