Skip to content

Commit 2f1482d

Browse files
Fix null checking for optional key and segments
1 parent 964a3cf commit 2f1482d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Octopus.OpenFeature.Provider/OctopusFeatureContext.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ bool Evaluate(FeatureToggleEvaluation evaluation, EvaluationContext? context = n
7676
{
7777
return false;
7878
}
79+
if (evaluation.EvaluationKey == null)
80+
{
81+
throw new InvalidOperationException($"Enabled feature toggles require an evaluation key.");
82+
}
7983

8084
var targetingKey = context?.TargetingKey;
8185
if (targetingKey == null || targetingKey == "")
@@ -93,7 +97,7 @@ bool Evaluate(FeatureToggleEvaluation evaluation, EvaluationContext? context = n
9397
}
9498
}
9599

96-
return evaluation.Segments.Length == 0 || MatchesSegment(context, evaluation.Segments);
100+
return evaluation.Segments == null || evaluation.Segments.Length == 0 || MatchesSegment(context, evaluation.Segments);
97101
}
98102

99103
/// <summary>

0 commit comments

Comments
 (0)