Skip to content

Commit 9880f21

Browse files
fix: corrected logic for rollout services (#296)
1 parent 754558b commit 9880f21

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pkg/decision/rollout_service.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ func (r RolloutService) GetDecision(decisionContext FeatureDecisionContext, user
7474
featureDecision.Decision = decision.Decision
7575
}
7676

77-
featureDecision.Experiment = *experiment
7877
featureDecision.Variation = decision.Variation
78+
if featureDecision.Variation != nil {
79+
featureDecision.Experiment = *experiment
80+
}
7981
r.logger.Debug(fmt.Sprintf(`Decision made for user "%s" for feature rollout with key "%s": %s.`, userContext.ID, feature.Key, featureDecision.Reason))
8082
return featureDecision, nil
8183
}

pkg/decision/rollout_service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (s *RolloutServiceTestSuite) TestGetDecisionWhenFallbackBucketingFails() {
199199
logger: s.mockLogger,
200200
}
201201
expectedFeatureDecision := FeatureDecision{
202-
Experiment: testExp1118,
202+
Experiment: entities.Experiment{}, // should not populate good experiment on nil variation
203203
Source: Rollout,
204204
Decision: Decision{Reason: reasons.FailedRolloutBucketing},
205205
}

0 commit comments

Comments
 (0)