Skip to content

fix: Serve multivariate segment overrides their variant under local evaluation - #128

Merged
gagantrivedi merged 1 commit into
mainfrom
fix/segment-override-multivariate
Nov 9, 2026
Merged

gagantrivedi merged 1 commit into
mainfrom
fix/segment-override-multivariate

Conversation

@gagantrivedi

Copy link
Copy Markdown
Member

Under local evaluation, a segment override with a multivariate split served every identity in the segment the override's control value. No identity ever got a variant. This affects every experiment, since an experiment's rollout is a segment override.

Cause

The segment mapper built overrides without their multivariate_feature_state_values. The environment mapper maps them for environment features, but the segment mapper had its own copy that didn't.

Changes

  • Segment overrides are now mapped with Environment.build_feature_hash, the same function as environment features, so the two can't drift apart again.
  • A test maps a segment override with a 100% variant and checks that an identity in the segment gets the variant. It fails without the fix.

Why tests didn't catch it

engine-test-data feeds the engine a ready-made evaluation context, so it never runs the SDK's mapper from the environment document.

…valuation

Segment overrides were mapped without their multivariate values, so every
identity in the segment got the override's control value. Map them the same
way as environment features.
@gagantrivedi
gagantrivedi requested a review from a team as a code owner November 9, 2026 07:59
@gagantrivedi
gagantrivedi requested review from emyller and removed request for a team November 9, 2026 07:59
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

build_overrides now delegates feature-state mapping to Environment.build_feature_hash. A new test checks that a matching identity receives the configured multivariate variant and that evaluation returns segment_variant.

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

Merge Risk: Minimal · up to cf661

The change enables segment variants while preserving override precedence. No actionable merge-blocking issue remains; the benchmark check needs a retry after the external download timeout.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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: ASSERTIVE
  • Plan: Advanced
  • Run ID: c71609e4-9b17-49ad-bbf7-85b90277094c
Commits

Reviewing files that changed from the base of the PR and between a6ccd7f and cf66169.

Files selected for processing: 2

  • lib/flagsmith/engine/mappers/segments.rb
  • spec/engine/unit/evaluation_context_mappers_spec.rb

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

@gagantrivedi
gagantrivedi requested review from Zaimwa9 and removed request for emyller November 9, 2026 08:08
@gagantrivedi
gagantrivedi merged commit dbb7a83 into main Nov 9, 2026
9 of 10 checks passed
gagantrivedi pushed a commit that referenced this pull request Nov 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[5.2.0](v5.1.0...v5.2.0)
(2026-11-09)


### Features

* Support `getExperimentFlag`, `trackEvent` and `trackExposure` methods
([#127](#127))
([670b413](670b413))


### Bug Fixes

* Serve multivariate segment overrides their variant under local
evaluation
([#128](#128))
([dbb7a83](dbb7a83))


### Other

* Let Renovate keep updating spec bumps the webhook handler commits to
([#123](#123))
([a6ccd7f](a6ccd7f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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