Skip to content

fix(ofrep): use the code default without an error when a response has no value - #1997

Open
ajtaylor wants to merge 1 commit into
open-feature:mainfrom
ajtaylor:fix/ofrep-code-default
Open

ajtaylor wants to merge 1 commit into
open-feature:mainfrom
ajtaylor:fix/ofrep-code-default

Conversation

@ajtaylor

@ajtaylor ajtaylor commented Dec 1, 2026

Copy link
Copy Markdown

Fixes #1850.

flagd answers a disabled flag over OFREP with {"key":"off-flag","reason":"DISABLED","metadata":{}}. Resolver#handleResolved treated the missing value as FLAG_NOT_FOUND ("No value returned for flag") and dropped the reason, so the application saw reason ERROR and an error code that suggests a misspelt flag key.

OFREP's evaluationSuccess requires only key and reason, and its codeDefaultFlag has no value: "the provider must use the code default value". A response without a value now returns the code default with the response's reason, variant and metadata, and no error. handleResolved no longer needs the key parameter (PMD's UnusedFormalParameter), so it's removed.

Testing:

  • New testCodeDefaultResponse, with flagd's response body as raw JSON: the default, reason DISABLED, no variant, no error code or message.
  • New testCodeDefaultResponseWithVariant: a STATIC response with a variant but no value gives the default with reason STATIC and the response's variant, and no error.
  • Both fail without the change. mvn -pl providers/ofrep verify passes: 20 tests, plus Checkstyle, PMD and Spotless (JDK 21, Maven 3.9.9).

@ajtaylor
ajtaylor requested a review from a team as a code owner December 1, 2026 20:30
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

For HTTP 200 responses without a value, the resolver now returns the caller’s default while preserving the response reason and variant. It no longer reports FLAG_NOT_FOUND or an error message for this case.

Changes: OFREP code-default responses

Layer / File(s) Summary
Resolve responses without a value
providers/ofrep/src/main/java/dev/openfeature/contrib/providers/ofrep/internal/Resolver.java, providers/ofrep/src/test/java/dev/openfeature/contrib/OfrepProviderTest.java
The HTTP 200 handler returns the caller’s default and preserves the response reason and variant when the response has no value. Tests cover responses with and without a variant, and verify that the error code and message are null.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: rahul-baradol, aepfli, toddbaert

Merge Risk: Minimal · up to 35bd7

Value-less OFREP success responses, such as a disabled flag, now return the code default with the server's reason and variant instead of a not-found error. The change is narrow and covered by new tests, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the OFREP provider fix: a response without a value now returns the code default without an error. This matches the main change in Resolver.java and the new tests. It is specific and fo…
Description check Passed The description states the problem (flagd disabled flag returned as FLAG_NOT_FOUND), the fix (code default with response reason, variant and metadata, no error), the removed key parameter, and the two…
Linked Issues check Passed [#1850] The issue requires that an OFREP response without value (codeDefaultFlag) return the code default, keep the response's reason, variant and metadata, and report no error. At head, `Resolver.h…
Out of Scope Changes check Passed The changes are limited to the OFREP provider. The Resolver.java change is the null-value branch in handleResolved and the removal of the unused key parameter, which the PR states is needed to c…
Full details: Title check

Explanation

The title names the OFREP provider fix: a response without a value now returns the code default without an error. This matches the main change in Resolver.java and the new tests. It is specific and follows the conventional commit style.

Full details: Description check

Explanation

The description states the problem (flagd disabled flag returned as FLAG_NOT_FOUND), the fix (code default with response reason, variant and metadata, no error), the removed key parameter, and the two new tests. It is directly related to the changeset.

Full details: Linked Issues check

Explanation

[#1850] The issue requires that an OFREP response without value (codeDefaultFlag) return the code default, keep the response's reason, variant and metadata, and report no error. At head, Resolver.handleResolved checks responseValue == null before the type check. That branch returns defaultValue with response.getReason(), response.getVariant() and the converted flagMetadata, and sets no errorCode or errorMessage. The previous FLAG_NOT_FOUND path is removed from this case. The key parameter is removed from handleResolved, and resolve passes responseBody and immutableMetadata to it. The key is not part of ProviderEvaluation, so it cannot be preserved as a field. The issue's question about whether FLAG_NOT_FOUND is deliberate is answered by this change. Type-mismatch and successful-value handling are unchanged. The PR adds testCodeDefaultResponse (DISABLED, no variant, no error) and testCodeDefaultResponseWithVariant (STATIC with variant, no error) to cover the issue's cases. I did not re-run the tests. The test evidence is the PR description and the summary.

Full details: Out of Scope Changes check

Explanation

The changes are limited to the OFREP provider. The Resolver.java change is the null-value branch in handleResolved and the removal of the unused key parameter, which the PR states is needed to clear a PMD finding. Both match #1850. The added tests in OfrepProviderTest cover the same null-value behaviour and support the change. No unrelated behaviour change appears in the reviewed summary or in the head Resolver.java. Non-null value handling, type-mismatch handling, and the error mapping for other status codes are unchanged.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1392fda7-1d1e-40ba-a590-bd32fd2e3cf7
Commits

Reviewing files that changed from the base of the PR and between d269b98 and 35bd718.

Files selected for processing: 2

  • providers/ofrep/src/main/java/dev/openfeature/contrib/providers/ofrep/internal/Resolver.java
  • providers/ofrep/src/test/java/dev/openfeature/contrib/OfrepProviderTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

This branch has not been deployed

No deployments
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.

[OFREP] Should the provider handle codeDefaultFlag responses? Disabled flags surface FLAG_NOT_FOUND

1 participant