Skip to content

feat: Add reason, variant to flagsmith eval output - #74

Draft
khvn26 wants to merge 1 commit into
mainfrom
feat/eval-reason
Draft

feat: Add reason, variant to flagsmith eval output#74
khvn26 wants to merge 1 commit into
mainfrom
feat/eval-reason

Conversation

@khvn26

@khvn26 khvn26 commented Aug 7, 2026

Copy link
Copy Markdown
Member

Closes #73.

$ flagsmith eval --identity test-id
FEATURE             ENABLED   VALUE           VARIANT   REASON
beta_dashboard      on        preview                   TARGETING_MATCH; segment=identity_overrides
checkout_button     on        blue_button     blue      SPLIT; weight=50
max_items           on        25                        DEFAULT
priority_support    on        24h                       TARGETING_MATCH; segment=Power users
  • reason and variant in --json, the table and the detail view, from Flag.Reason/Flag.Variant
  • Both omitempty: an SDK API reporting neither renders exactly as it does today
  • A column appears only where something would go in it

Drafted until flagsmith-go-client#221 is released.

Note the core API sends variant only, on POST /identities/reason comes from Edge.

`eval` has only ever said what an SDK resolves, never why. A flag that is on
because of a segment override, an identity override or a percentage split all
looked identical, so answering "why is this on for that user" meant leaving the
terminal for the dashboard.

flagsmith-go-client#221 puts `Reason` and `Variant` on `Flag`, populated from
the engine in local evaluation and from the `reason` and `variant` fields of
`/flags` and `/identities` remotely. This surfaces both.

Both are `omitempty` rather than always present. The EvaluationResult schema
marks them required, but an SDK API that predates them reports neither, and no
variant applies to a standard feature or to an evaluation with no identity to
bucket. An empty string would read as a reason of its own, so absence is the
honest answer — the same treatment `segments` already gets, and what keeps
`--json` a subset rather than a fiction.

The table grows a column only where there is something to put in it, so an API
reporting neither renders exactly as it does today. `--js` is deliberately
untouched: a frontend SDK hydrates from enabled and value, and anything else is
state it would carry without ever reading.

go.mod pins a pseudo-version until #221 is merged and released.

beep boop
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fd184931-cbdd-44d8-b081-6affe567a526

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khvn26 khvn26 changed the title feat: Report why each flag resolved in flagsmith eval feat: Add reason, variant to flagsmith eval output Aug 7, 2026
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.

Add reason, variant to flagsmith eval output

1 participant