-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Trait data is seemingly being ignored in identity evaluations. Likely root cause is the Node.js SDK cache key not including traits, which can cause different trait sets to return the same cached evaluation result.
Problem description
Trait data is “seemingly getting ignored” during evaluations. https://github.com/Flagsmith/flagsmith-nodejs-client/blob/main/sdk/index.ts#L223
Likely root cause
The cache key currently does not incorporate trait values. If the same identity (or request context) is evaluated with different traits, the SDK may return a previously cached result that was computed for a different trait set.
Technical notes / impact
• The SDK supports external cache implementations (for example Redis) via the cache option in the Flagsmith constructor.
• Including traits in the cache key will change the key format and cache behavior.
• For Redis or any shared backing store, changing the key format is likely a breaking change because existing cache entries become unreachable under the new format (and any custom tooling that expects the old key format may break).
Proposed directions (for evaluation)
Option A (backward compatible default)
Add a constructor option, for example:
• includeTraitsInCacheKey: boolean (default false)
When enabled:
• Cache key incorporates a stable serialization of traits (and trait order is normalized)
• Existing users keep current behavior unless they opt in
Option B (intentional breaking change)
Always include traits in the cache key by default.
• Would require a major version release
• Requires explicit migration guidance in release notes