Strictly check variant types in Flag Evaluations#11036
Open
Strictly check variant types in Flag Evaluations#11036
Conversation
Check the requested evaluation type against the flag's declared variationType before calling mapValue(). Return TYPE_MISMATCH when they don't match (e.g., STRING flag evaluated as Boolean). Separately, variant values that don't match their declared type (e.g., INTEGER flag with string variant value) now return PARSE_ERROR instead of TYPE_MISMATCH, aligning with Go SDK (dd-trace-go#4590) and Python's libdatadog behavior. Type compatibility mapping: BOOLEAN → Boolean.class STRING → String.class INTEGER → Integer.class NUMERIC → Double.class JSON → Value.class
Contributor
|
Hey @typotter 👋 Can you make sure the PR title follows the title format contribution guideline? |
greghuels
approved these changes
Apr 2, 2026
Contributor
Author
done, thanks! |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Adds strict type checking to
DDEvaluatorso that requesting a flag evaluation with a type that doesn't match the flag's declaredvariationTypereturnsTYPE_MISMATCHinstead of silently coercing the value.Also distinguishes variant value parse errors (broken config) from request type mismatches:
TYPE_MISMATCH(e.g., STRING flag evaluated as Boolean)PARSE_ERROR(e.g., INTEGER flag with string variant value)Motivation
Aligns the Java SDK with Python (libdatadog) and Go (dd-trace-go#4590) type checking behavior. Previously, Java's
mapValue()silently coerced types —Boolean.valueOf("on-value")returnedfalseinstead of erroring, andparseDouble("123").intValue()returned123instead of reporting a type mismatch.Cross-tracer consistency is required for the FFE eval metrics system tests to pass (solves 2 of the 6 remaining test failures).
Type compatibility mapping:
variationTypeBoolean.classString.classInteger.classDouble.classValue.classReferences:
flag_type.rsbitwise type checkAdditional Notes
Contributor Checklist
type:and (comp:orinst:) labelsclose,fix, or any linking keywords when referencing an issueJira ticket: FFL-1972