Skip to content

fix(ofrep): use the code default when a success response has no value or variant - #358

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

Summary of Changes

flagd answers a disabled flag over OFREP with no value and no variant:

$ curl -s -X POST localhost:8016/ofrep/v1/evaluate/flags/off-flag -d '{"context":{"targetingKey":"u"}}'
{"key":"off-flag","reason":"DISABLED","metadata":{}}

Client#parse_success_response required key value reason variant, so this raised ParseError and the application got its default with PARSE_ERROR and reason ERROR. OFREP's evaluationSuccess requires only key and reason. variant is optional, and since OFREP 0.2.0 (open-feature/protocol#49) value may be left out too: codeDefaultFlag has no value, and "the provider must use the code default value when processing this response".

  • parse_success_response now requires only key and reason.
  • Provider#evaluate returns the code default, with the response's reason, variant and metadata, when the response has no value. Before, the check for DISABLED covered disabled flags, but any other code-default response (e.g. STATIC) would have failed the type check with TYPE_MISMATCH.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Testing

  • Client: a 200 with only key, reason and metadata parses, and so does a 200 with a value but no variant. The existing "missing required keys" test now leaves out reason, which is still required, in place of value.
  • Provider: DISABLED with no value or variant gives the default with reason DISABLED; STATIC with no value gives the default with reason STATIC and the metadata.
  • The four new tests fail without the change. bundle exec rspec (48 examples) and bundle exec rubocop pass.
  • Checked against flagd v0.18.2: a disabled flag gives false, DISABLED, no error; an enabled one still gives its value.

Checklist

  • Tests pass (bundle exec rspec)
  • Linter passes (bundle exec rubocop)
  • PR title follows Conventional Commits

… or variant

Signed-off-by: Tony Taylor <antony.taylor@gmail.com>
@ajtaylor
ajtaylor requested a review from a team as a code owner December 1, 2026 20:26
@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

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: fa5a7d7d-4270-4251-9f89-46b6efcf43c1
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

2 participants