Skip to content

feat(core)!: null resolve variants and free-form reasons - #2140

Merged
toddbaert merged 3 commits into
mainfrom
feat/resolve-null-variant
Nov 30, 2026
Merged

toddbaert merged 3 commits into
mainfrom
feat/resolve-null-variant

Conversation

@toddbaert

@toddbaert toddbaert commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Implements the resolve changes from #2139: a null variant falls back like a plain null, and reasons are free-form.

  • null variant: {"resolve": [null, ...]} shares the plain-null path (defaultVariant, or no value), plus the rule's reason and metadata
  • reasons: no reserved reasons; a rule's reason is passed through and never changes the outcome
  • no value: decided by an empty variant, not by the reason, on gRPC v2 and OFREP (single and bulk)

FALLBACK, removed:

  • Problem: the evaluator returns a Go T, which can't be nil, so "no value" and "the value is false" look the same. The v2 and OFREP layers needed one extra bit to tell them apart.
  • Solution (before): carry that bit in the reason, as a special internal value, mapped to DEFAULT on the way out.
  • This PR carries the same bit in the variant instead (empty means no value), which every result already includes.

Breaking for flagd/core consumers: model.FallbackReason is gone; check for an empty variant instead. The Go provider needs that change when it bumps core. Wire output is unchanged (basically this is an "internal only" break in flagd-core) - we don't really need to do it here, but I think it's worth it.

📓 The break (!) here only impacts the internal flagd-core library.

@netlify

netlify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit 05745f7
🔍 Latest deploy log https://app.netlify.com/projects/polite-licorice-3db33c/deploys/6b09cdf1e1da1b4d57c59153

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The evaluator now accepts null resolve variants, applies configured or caller defaults, and passes supplied reasons through. OFREP and flagd V2 omit values and variants when evaluation succeeds with an empty variant. The FallbackReason constant was removed, and the resolve operation documentation describes the updated behavior.

Changes: Resolve result handling

Layer / File(s) Summary
Null resolution and reason propagation
core/pkg/evaluator/..., core/pkg/model/reason.go, docs/reference/custom-operations/resolve-operation.md
Resolve parsing accepts null variants and applies configured or caller defaults. Supplied reasons pass through unchanged. Tests and documentation cover these behaviors.
OFREP response projection
core/pkg/service/ofrep/...
OFREP omits the value and variant for empty-variant results and preserves the result reason. Tests cover default and custom reasons.
flagd V2 response projection
flagd/pkg/service/flag-evaluation/...
flagd V2 returns a reason-only response when evaluation succeeds with an empty variant. Tests cover custom and default reasons.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant parseEvaluatedResolve
  participant applyResolveResult
  participant nullResult
  parseEvaluatedResolve->>applyResolveResult: parsed result and context
  applyResolveResult->>nullResult: null result, flag, and context
  nullResult-->>applyResolveResult: variant, reason, metadata, and error
  applyResolveResult-->>parseEvaluatedResolve: resolved result
Loading

Possibly related issues

Possibly related PRs

Merge Risk: Minimal · up to 05745

A null or empty variant now falls back to the configured default or to no value, and the rule's reason is passed through. The change is mostly internal: FallbackReason is removed from flagd/core, so downstream consumers such as the Go provider must check for an empty variant when they upgrade. No concrete merge-blocking problem was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(core)!: null resolve variants and free-form reasons" matches the main changes: null variants now follow the plain-null path, and reasons are no longer reserved and do not change outcom…
Description check Passed The description states the goals: null variants share the plain-null path, reasons are free-form, and empty variants signal no value on gRPC v2 and OFREP. It explains the removal of FALLBACK and the b…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(core)!: null resolve variants and free-form reasons" matches the main changes: null variants now follow the plain-null path, and reasons are no longer reserved and do not change outcomes. The breaking marker matches the removal of model.FallbackReason. The title is concise and specific, though it omits the removal of FALLBACK as the no-value signal.

Full details: Description check

Explanation

The description states the goals: null variants share the plain-null path, reasons are free-form, and empty variants signal no value on gRPC v2 and OFREP. It explains the removal of FALLBACK and the breaking change for flagd/core consumers. This matches the changeset in the resolver, OFREP, flagd v2 evaluator, and reason model files.

  • 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: 2618e4b2-3b81-4d68-918e-1d17467b5bec
Commits

Reviewing files that changed from the base of the PR and between 113f95d and 05745f7.

Files selected for processing: 3

  • core/pkg/evaluator/json.go
  • core/pkg/service/ofrep/models.go
  • flagd/pkg/service/flag-evaluation/flag_evaluator_v2.go
Files skipped from review as they are similar to previous changes: 3

  • core/pkg/evaluator/json.go
  • core/pkg/service/ofrep/models.go
  • flagd/pkg/service/flag-evaluation/flag_evaluator_v2.go

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

BREAKING CHANGE: model.FallbackReason is removed; a result with no value now has an empty variant and reason DEFAULT.

Signed-off-by: Todd Baert <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@suthar26 suthar26 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.

this makes the code a lot easier to read imo, and keeps the mental model simpler

@toddbaert
toddbaert merged commit 8d36800 into main Nov 30, 2026
17 checks passed
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