Skip to content

feat(openfeature): support long variable evaluation - #196

Open
jonathannorris wants to merge 2 commits into
mainfrom
worktree-of-long-support
Open

feat(openfeature): support long variable evaluation#196
jonathannorris wants to merge 2 commits into
mainfrom
worktree-of-long-support

Conversation

@jonathannorris

@jonathannorris jonathannorris commented Jul 30, 2026

Copy link
Copy Markdown
Member

Enables Long variable evaluation in the DevCycle OpenFeature provider, per the OpenFeature Java SDK 1.22.0 call to action.

Change

  • Bump dev.openfeature:sdk from 1.14.2 to 1.22.0 (the release that adds getLongEvaluation to FeatureProvider).

Why no custom override

DevCycle has no native long type: internally all numbers are stored as Doubles. The 1.22.0 default getLongEvaluation already delegates to getDoubleEvaluation (DevCycle's native number path) and then safely narrows the result to a long, returning TYPE_MISMATCH when the value is fractional, NaN/Infinite, or outside the double safe-integer range (±(2^53−1)).

A hand-rolled override would add no capability (DevCycle still can't represent values beyond 2^53) and would only remove that guarding by silently truncating/saturating. So the provider intentionally relies on the SDK default.

Note: the community message described the default as delegating to Integer, but the shipped 1.22.0 bytecode delegates to getDoubleEvaluation — which is the ideal path for a Double-backed provider like DevCycle.

Testing

Added tests in DevCycleProviderTest that lock in the default behavior:

  • value beyond int range (5e9) resolves to the correct long;
  • fractional value (10.5) returns TYPE_MISMATCH;
  • value at 2^53 (outside safe range) returns TYPE_MISMATCH.

./gradlew test --tests com.devcycle.sdk.server.openfeature.* passes.

@jonathannorris jonathannorris changed the title feat(openfeature): add long variable support feat(openfeature): support long variable evaluation Jul 30, 2026
@jonathannorris
jonathannorris marked this pull request as ready for review July 30, 2026 15:46
@jonathannorris
jonathannorris requested a review from a team as a code owner July 30, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the DevCycle OpenFeature provider integration to support Long evaluations by upgrading the OpenFeature Java SDK to a version that includes FeatureProvider#getLongEvaluation, and adds regression tests to validate the SDK default narrowing behavior for Double-backed numbers.

Changes:

  • Bump dev.openfeature:sdk from 1.14.2 to 1.22.0.
  • Add DevCycleProviderTest coverage for getLongEvaluation (beyond-int range success, fractional mismatch, and unsafe-range mismatch).

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
build.gradle Bumps OpenFeature SDK dependency to 1.22.0 to enable long evaluation support.
src/test/java/com/devcycle/sdk/server/openfeature/DevCycleProviderTest.java Adds tests that exercise the OpenFeature SDK default getLongEvaluation behavior against DevCycle’s Double-backed numeric variables.
Comments suppressed due to low confidence (1)

src/test/java/com/devcycle/sdk/server/openfeature/DevCycleProviderTest.java:223

  • This comment attributes the mismatch to precision loss, but 2^53 is exactly representable as a double. The reason it should be rejected is that it is outside the SDK’s declared safe-integer range (max 2^53−1). Updating the wording makes the test rationale accurate.
        // 2^53 exceeds the double safe-integer range, so it cannot be narrowed to a long without precision loss.
        Double variableValue = 9_007_199_254_740_992.0;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

IDevCycleClient dvcClient = mock(IDevCycleClient.class);
when(dvcClient.isInitialized()).thenReturn(true);

// 5_000_000_000 exceeds Integer.MAX_VALUE but is well within the double safe-integer range (2^53).

@toddbaert toddbaert left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there official docs about the 2^53 limitation?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants