Skip to content

Strictly check variant types in Flag Evaluations#11036

Open
typotter wants to merge 1 commit intomasterfrom
typo/evaluator-type-mismatch
Open

Strictly check variant types in Flag Evaluations#11036
typotter wants to merge 1 commit intomasterfrom
typo/evaluator-type-mismatch

Conversation

@typotter
Copy link
Copy Markdown
Contributor

@typotter typotter commented Apr 2, 2026

What Does This Do

Adds strict type checking to DDEvaluator so that requesting a flag evaluation with a type that doesn't match the flag's declared variationType returns TYPE_MISMATCH instead of silently coercing the value.

Also distinguishes variant value parse errors (broken config) from request type mismatches:

  • Request type vs flag variationTypeTYPE_MISMATCH (e.g., STRING flag evaluated as Boolean)
  • Variant value vs declared typePARSE_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") returned false instead of erroring, and parseDouble("123").intValue() returned 123 instead 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:

variationType Valid Java type
BOOLEAN Boolean.class
STRING String.class
INTEGER Integer.class
NUMERIC Double.class
JSON Value.class

References:

Additional Notes

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels
  • Avoid using close, fix, or any linking keywords when referencing an issue

Jira ticket: FFL-1972

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
@typotter typotter added type: bug Bug report and fix tag: ai generated Largely based on code generated by an AI or LLM comp: openfeature OpenFeature labels Apr 2, 2026
@typotter typotter marked this pull request as ready for review April 2, 2026 05:18
@typotter typotter requested a review from a team as a code owner April 2, 2026 05:18
@typotter typotter requested review from greghuels and leoromanovsky and removed request for a team April 2, 2026 05:18
@PerfectSlayer
Copy link
Copy Markdown
Contributor

Hey @typotter 👋 Can you make sure the PR title follows the title format contribution guideline?
As the PR title goes straight into the release log for customers, please reword them accordingly :) Thanks!

@typotter typotter changed the title fix(openfeature): strict type checking for flag evaluations Strictly check variant types in Flag Evaluations Apr 2, 2026
@typotter
Copy link
Copy Markdown
Contributor Author

typotter commented Apr 2, 2026

Hey @typotter 👋 Can you make sure the PR title follows the title format contribution guideline? As the PR title goes straight into the release log for customers, please reword them accordingly :) Thanks!

done, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: openfeature OpenFeature tag: ai generated Largely based on code generated by an AI or LLM type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants