Conversation
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThis PR adds LONG as a supported flag value type across the SDK. It introduces a ChangesLong Flag Value Type Support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant OpenFeatureClient
participant FeatureProvider
participant DoubleEvaluationSource
Caller->>OpenFeatureClient: getLongValue(key, default, ctx, options)
OpenFeatureClient->>OpenFeatureClient: evaluateFlag(FlagValueType.LONG, ...)
OpenFeatureClient->>FeatureProvider: getLongEvaluation(key, default, ctx)
alt provider overrides getLongEvaluation
FeatureProvider-->>OpenFeatureClient: ProviderEvaluation<Long>
else default delegation
FeatureProvider->>DoubleEvaluationSource: getDoubleEvaluation(key, doubleDefault, ctx)
DoubleEvaluationSource-->>FeatureProvider: ProviderEvaluation<Double>
FeatureProvider->>FeatureProvider: validate finite/integral/safe-range
FeatureProvider-->>OpenFeatureClient: ProviderEvaluation<Long>
end
OpenFeatureClient-->>Caller: Long value
Related issues: Suggested labels: enhancement, api Suggested reviewers: none identified from provided context 🐰 A long-tailed rabbit hops with glee, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/dev/openfeature/sdk/providers/memory/InMemoryProvider.java (1)
159-176: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winValidate the context-evaluator result before returning it. The targeting path still returns
flag.getContextEvaluator().evaluate(...)directly, so anIntegercan escape as the value of aProviderEvaluation<Long>without theisAssignableTo/coerceVariantwidening used on the default-variant path. Apply the same check/coercion here or fail withTypeMismatchError.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/dev/openfeature/sdk/providers/memory/InMemoryProvider.java` around lines 159 - 176, The targeting branch in InMemoryProvider’s evaluation logic returns the raw result from flag.getContextEvaluator().evaluate(...) without validating or widening it like the default-variant path. Update the context-evaluator flow to run the same isAssignableTo check and coerceVariant conversion before assigning value, or throw TypeMismatchError when the evaluated variant cannot satisfy the expected type. Use the evaluate helper path and the existing type-handling logic in InMemoryProvider to keep behavior consistent across targeting and default resolution.
🧹 Nitpick comments (1)
src/main/java/dev/openfeature/sdk/FeatureProvider.java (1)
130-155: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor duplication: reuse
isWithinSafeRangeand consolidatelongErroroverloads.
Math.abs(value) > MAX_SAFE_INTEGERre-implements the same range check asisWithinSafeRange(long)(oncevalueis confirmed integral,(long) valueis safe to pass). Also, the twolongErroroverloads duplicate most builder fields, differing only invariant/flagMetadata.♻️ Optional consolidation
- if (Math.abs(value) > MAX_SAFE_INTEGER) { + if (!isWithinSafeRange((long) value)) { return longError( defaultValue, "Value " + value + " exceeds safe integer range [-(2^53 - 1), 2^53 - 1] for long", result); } ... - private static ProviderEvaluation<Long> longError(Long defaultValue, String message) { - return ProviderEvaluation.<Long>builder() - .value(defaultValue) - .reason(Reason.ERROR.toString()) - .errorCode(ErrorCode.TYPE_MISMATCH) - .errorMessage(message) - .build(); - } - - // preserve upstream metadata/variant; override with type error - private static ProviderEvaluation<Long> longError( - Long defaultValue, String message, ProviderEvaluation<Double> upstream) { - return ProviderEvaluation.<Long>builder() - .value(defaultValue) - .reason(Reason.ERROR.toString()) - .errorCode(ErrorCode.TYPE_MISMATCH) - .errorMessage(message) - .variant(upstream.getVariant()) - .flagMetadata(upstream.getFlagMetadata()) - .build(); - } + private static ProviderEvaluation<Long> longError(Long defaultValue, String message) { + return longError(defaultValue, message, null); + } + + // preserve upstream metadata/variant when available; override with type error + private static ProviderEvaluation<Long> longError( + Long defaultValue, String message, ProviderEvaluation<Double> upstream) { + var builder = ProviderEvaluation.<Long>builder() + .value(defaultValue) + .reason(Reason.ERROR.toString()) + .errorCode(ErrorCode.TYPE_MISMATCH) + .errorMessage(message); + if (upstream != null) { + builder.variant(upstream.getVariant()).flagMetadata(upstream.getFlagMetadata()); + } + return builder.build(); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/dev/openfeature/sdk/FeatureProvider.java` around lines 130 - 155, The `FeatureProvider` helpers duplicate range and error-building logic. Update the integral conversion path to call `isWithinSafeRange(long)` instead of rechecking with `Math.abs`, and consolidate the two `longError` overloads by sharing the common `ProviderEvaluation` builder setup in one helper while preserving the optional `variant` and `flagMetadata` from the upstream value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/dev/openfeature/sdk/providers/memory/InMemoryProvider.java`:
- Line 173: The error message in InMemoryProvider’s type mismatch path is
missing a space before “is”, causing malformed output. Update the
TypeMismatchError message in the relevant flag-checking logic so the
concatenated text reads naturally, using the same key variable and error
construction in InMemoryProvider.
---
Outside diff comments:
In `@src/main/java/dev/openfeature/sdk/providers/memory/InMemoryProvider.java`:
- Around line 159-176: The targeting branch in InMemoryProvider’s evaluation
logic returns the raw result from flag.getContextEvaluator().evaluate(...)
without validating or widening it like the default-variant path. Update the
context-evaluator flow to run the same isAssignableTo check and coerceVariant
conversion before assigning value, or throw TypeMismatchError when the evaluated
variant cannot satisfy the expected type. Use the evaluate helper path and the
existing type-handling logic in InMemoryProvider to keep behavior consistent
across targeting and default resolution.
---
Nitpick comments:
In `@src/main/java/dev/openfeature/sdk/FeatureProvider.java`:
- Around line 130-155: The `FeatureProvider` helpers duplicate range and
error-building logic. Update the integral conversion path to call
`isWithinSafeRange(long)` instead of rechecking with `Math.abs`, and consolidate
the two `longError` overloads by sharing the common `ProviderEvaluation` builder
setup in one helper while preserving the optional `variant` and `flagMetadata`
from the upstream value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 56880d00-46b7-4979-b108-be72f986954a
📒 Files selected for processing (15)
src/main/java/dev/openfeature/sdk/Client.javasrc/main/java/dev/openfeature/sdk/FeatureProvider.javasrc/main/java/dev/openfeature/sdk/Features.javasrc/main/java/dev/openfeature/sdk/FlagValueType.javasrc/main/java/dev/openfeature/sdk/LongHook.javasrc/main/java/dev/openfeature/sdk/OpenFeatureClient.javasrc/main/java/dev/openfeature/sdk/Value.javasrc/main/java/dev/openfeature/sdk/providers/memory/InMemoryProvider.javasrc/test/java/dev/openfeature/sdk/FlagEvaluationSpecTest.javasrc/test/java/dev/openfeature/sdk/HookSupportTest.javasrc/test/java/dev/openfeature/sdk/LongDefaultDelegationTest.javasrc/test/java/dev/openfeature/sdk/LongHookTest.javasrc/test/java/dev/openfeature/sdk/fixtures/HookFixtures.javasrc/test/java/dev/openfeature/sdk/providers/memory/InMemoryProviderTest.javasrc/test/java/dev/openfeature/sdk/testutils/testProvider/TestProvider.java
Added fix and related test. |
* adds long support to client/provider * delegates to provider int resolver by default * widens, rejecting unsafe defaults * providers supporting Long should implement manually Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1985 +/- ##
============================================
+ Coverage 92.23% 92.84% +0.60%
- Complexity 669 704 +35
============================================
Files 59 60 +1
Lines 1635 1704 +69
Branches 186 195 +9
============================================
+ Hits 1508 1582 +74
+ Misses 80 74 -6
- Partials 47 48 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|



Closes: #501