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
758fbd5b84

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
This commit is contained in:
Todd Baert 2025-07-15 14:19:15 -04:00 committed by GitHub
parent 961f9a6e13
commit 6cabfc8ff3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -390,7 +390,7 @@ func (je *Resolver) evaluateVariant(ctx context.Context, reqID string, flagKey s
} }
je.Logger.ErrorWithID(reqID, je.Logger.ErrorWithID(reqID,
fmt.Sprintf("invalid or missing variant: %s for flagKey: %s, variant is not valid", variant, flagKey)) fmt.Sprintf("invalid or missing variant: %s for flagKey: %s, variant is not valid", variant, flagKey))
return "", flag.Variants, model.ErrorReason, metadata, errors.New(model.ParseErrorCode) return "", flag.Variants, model.ErrorReason, metadata, errors.New(model.GeneralErrorCode)
} }
if flag.DefaultVariant == "" { if flag.DefaultVariant == "" {

View File

@ -196,7 +196,7 @@ func TestLegacyFractionalEvaluation(t *testing.T) {
expectedVariant: "", expectedVariant: "",
expectedValue: "", expectedValue: "",
expectedReason: model.ErrorReason, expectedReason: model.ErrorReason,
expectedErrorCode: model.ParseErrorCode, expectedErrorCode: model.GeneralErrorCode,
}, },
"fallback to default variant if invalid variant as result of fractional evaluation": { "fallback to default variant if invalid variant as result of fractional evaluation": {
flags: Flags{ flags: Flags{
@ -229,7 +229,7 @@ func TestLegacyFractionalEvaluation(t *testing.T) {
expectedVariant: "", expectedVariant: "",
expectedValue: "", expectedValue: "",
expectedReason: model.ErrorReason, expectedReason: model.ErrorReason,
expectedErrorCode: model.ParseErrorCode, expectedErrorCode: model.GeneralErrorCode,
}, },
"fallback to default variant if percentages don't sum to 100": { "fallback to default variant if percentages don't sum to 100": {
flags: Flags{ flags: Flags{