fix: unwrap TraitConfig values in local evaluation before segment matching#252
Merged
fix: unwrap TraitConfig values in local evaluation before segment matching#252
Conversation
Add tests verifying that segment matching works correctly when traits
are passed using the TraitConfig format ({ value, transient }) in
local evaluation mode. These tests expose a bug where TraitConfig
objects are passed to the engine without unwrapping the actual value,
causing segment rules to never match.
Tests added:
- getIdentityFlags with plain traits matches segment (baseline)
- getIdentityFlags with TraitConfig format matches segment
- getIdentityFlags with mixed trait formats matches segment
- getIdentitySegments with TraitConfig format matches segment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ching
TraitConfig objects ({ value, transient }) were passed directly to the
evaluation engine without extracting the actual value. This caused
segment condition comparisons to fail (e.g. 'cedars' == { value: 'cedars',
transient: true } → false), so segment overrides were never applied.
The remote evaluation path already handled this correctly via
isTraitConfig() in generateIdentitiesData. This fix applies the same
unwrapping in getIdentityFlagsFromDocument and getIdentitySegments.
Fixes #238
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9bebed5 to
15d1894
Compare
khvn26
approved these changes
Mar 16, 2026
khvn26
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TraitConfigformat (e.g.{ value: 'gold', transient: true })TraitConfigobject was passed directly to the evaluation engine without extracting the.value, causing segment condition comparisons like'gold' == { value: 'gold', transient: true }to always returnfalseisTraitConfig()— this fix applies the same unwrapping ingetIdentityFlagsFromDocumentandgetIdentitySegmentsRoot Cause
In
sdk/index.ts, bothgetIdentityFlagsFromDocument(line 475) andgetIdentitySegments(line 278) mapped traits as:This passed the entire
TraitConfigobject{ value: 'gold', transient: true }as the trait value, instead of just'gold'.Fix
Use the existing
isTraitConfig()helper to unwrap values before passing to the engine:Validated Against Real Staging Environment
"segment override""default"(wrong)"segment override""segment override"Test plan
getIdentityFlagswith plain traits matches segment (baseline)getIdentityFlagswithTraitConfigformat matches segmentgetIdentityFlagswith mixed trait formats matches segmentgetIdentitySegmentswithTraitConfigformat matches segmentFixes #253
🤖 Generated with Claude Code