Skip to content

Commit 6cabfc8

Browse files
authored
fix: general err if targeting variant not in variants (#1680)
This makes the RPC mode consistent with our in-process evaluations when a variant is returned from targeting which is not in the variants list. Relates to open-feature/flagd-testbed@758fbd5 Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
1 parent 961f9a6 commit 6cabfc8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

core/pkg/evaluator/json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func (je *Resolver) evaluateVariant(ctx context.Context, reqID string, flagKey s
390390
}
391391
je.Logger.ErrorWithID(reqID,
392392
fmt.Sprintf("invalid or missing variant: %s for flagKey: %s, variant is not valid", variant, flagKey))
393-
return "", flag.Variants, model.ErrorReason, metadata, errors.New(model.ParseErrorCode)
393+
return "", flag.Variants, model.ErrorReason, metadata, errors.New(model.GeneralErrorCode)
394394
}
395395

396396
if flag.DefaultVariant == "" {

core/pkg/evaluator/legacy_fractional_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func TestLegacyFractionalEvaluation(t *testing.T) {
196196
expectedVariant: "",
197197
expectedValue: "",
198198
expectedReason: model.ErrorReason,
199-
expectedErrorCode: model.ParseErrorCode,
199+
expectedErrorCode: model.GeneralErrorCode,
200200
},
201201
"fallback to default variant if invalid variant as result of fractional evaluation": {
202202
flags: Flags{
@@ -229,7 +229,7 @@ func TestLegacyFractionalEvaluation(t *testing.T) {
229229
expectedVariant: "",
230230
expectedValue: "",
231231
expectedReason: model.ErrorReason,
232-
expectedErrorCode: model.ParseErrorCode,
232+
expectedErrorCode: model.GeneralErrorCode,
233233
},
234234
"fallback to default variant if percentages don't sum to 100": {
235235
flags: Flags{

0 commit comments

Comments
 (0)