Skip to content

feat(openfeature): map Source.Fallback.Reason to OpenFeature codes (SDK-130)#97

Draft
tylerjroach wants to merge 1 commit into
fix/sdk-79-variant-source-fallback-reasonfrom
tylerroach-sdk-130-java-openfeature-consume-fallback-reason
Draft

feat(openfeature): map Source.Fallback.Reason to OpenFeature codes (SDK-130)#97
tylerjroach wants to merge 1 commit into
fix/sdk-79-variant-source-fallback-reasonfrom
tylerroach-sdk-130-java-openfeature-consume-fallback-reason

Conversation

@tylerjroach

Copy link
Copy Markdown
Contributor

Summary

Completes SDK-79 for Java at the OpenFeature layer. Base PR #89 adds `Source.Fallback.Reason` to `SelectedVariant` but the OpenFeature wrapper still uses `result.isFallback()` and collapses every fallback into `ErrorCode.FLAG_NOT_FOUND`. This PR wires the wrapper to the reason.

Branch base

This PR is intentionally branched off `fix/sdk-79-variant-source-fallback-reason` (#89), not `master`, because `Source` doesn't exist on master yet. When #89 merges:

  1. This PR's base auto-flips to `master` (GitHub does this when the base branch is deleted)
  2. Rebase to drop the base commits and keep only wrapper diff
  3. Ready to review on top of merged master

Changes

  • `MixpanelProvider.java`:
    • Replace `result.isFallback()` → collapsed `FLAG_NOT_FOUND` with a dispatch on `result.getSource()`. When it's a `Source.Fallback`, call new `mapFallback` helper that switches on the reason.
    • Add `defaultResult` helper for the `NO_ROLLOUT_MATCH` case (spec: DEFAULT reason with no error).
  • `pom.xml`:
    • Bump wrapper version `0.1.1` → `0.2.0`
    • Bump base dep `mixpanel-java 1.8.0` → `1.10.0`. 1.10.0 is not yet tagged — release manager may pick a different next-version number; update accordingly.
  • `MixpanelProviderTest.java`: 4 new tests, one per `Source.Fallback.Reason` value.

Mapping table

Reason OpenFeature ErrorCode Reason
`FLAG_NOT_FOUND` `FLAG_NOT_FOUND` `DEFAULT`
`MISSING_CONTEXT_KEY` `TARGETING_KEY_MISSING` `ERROR`
`NO_ROLLOUT_MATCH` (none) `DEFAULT`
`BACKEND_ERROR` `GENERAL` `ERROR`
(unknown) `GENERAL` `ERROR`

Matches PHP/Python/Ruby.

Blocked on

Test plan

Refs: SDK-130, SDK-79

🤖 Generated with Claude Code

…DK-130)

Before: every fallback path collapsed to ErrorCode.FLAG_NOT_FOUND via
result.isFallback(). Callers debugging a missing-context-key or
backend-error scenario had no way to tell it from a typo in the flag
name.

After: dispatch on result.getSource(). When it's a Source.Fallback,
translate the reason to the OpenFeature ErrorCode + Reason the spec
assigns to it:

  FLAG_NOT_FOUND       -> ErrorCode.FLAG_NOT_FOUND, DEFAULT
  MISSING_CONTEXT_KEY  -> ErrorCode.TARGETING_KEY_MISSING, ERROR
  NO_ROLLOUT_MATCH     -> no error, DEFAULT (spec: not an error)
  BACKEND_ERROR        -> ErrorCode.GENERAL, ERROR
  unrecognized reason  -> ErrorCode.GENERAL (fail closed — a new reason
                          added to the base SDK enum without wiring here
                          surfaces as an error rather than a silent success)

Bump base pom dep from mixpanel-java 1.8.0 -> 1.10.0 (assumed next tag
containing SDK-79 / #89 — release manager may adjust). Bump wrapper
version 0.1.1 -> 0.2.0 (new capability surface).

Tests: 4 new cases covering each reason. Existing FLAG_NOT_FOUND tests
still pass — the 1-arg SelectedVariant constructor now defaults source
to Fallback(FLAG_NOT_FOUND).

Note: this PR is intentionally branched off fix/sdk-79-variant-source-fallback-reason
(#89) since the Source model class it depends on doesn't exist on
master yet. When #89 merges, rebase this branch onto master and only
the wrapper-side diff remains.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jul 21, 2026

Copy link
Copy Markdown

SDK-79

SDK-130

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

This looks safe to merge once the documented dependency release is available.

  • No blocking issues found in the changed code.
  • The new dispatch matches the fallback model used by the providers.
  • The tests cover every current fallback reason.

Important Files Changed

Filename Overview
openfeature-provider/pom.xml Updates the provider version and its mixpanel-java dependency.
openfeature-provider/src/main/java/com/mixpanel/openfeature/MixpanelProvider.java Maps each fallback source reason to the corresponding OpenFeature result.
openfeature-provider/src/test/java/com/mixpanel/openfeature/MixpanelProviderTest.java Adds focused tests for each supported fallback reason.

Reviews (1): Last reviewed commit: "feat(openfeature): map Source.Fallback.R..." | Re-trigger Greptile

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.

1 participant