[sdk/local-evaluation] Multivariate flag with overrides crashes on BigInt serialization (8.1.0) / resolves to a null variant (7.0.3)
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- nodejs, typescript
Research direction
Start with flagsmith-engine/evaluation/evaluationContext/mappers.js, especially mapIdentityOverridesToSegments and mapEnvironmentModelToEvaluationContext, then trace how sdk/index.js calls getIdentityFlagsFromDocument. Reproduce with local evaluation, a multivariate flag, segment and identity overrides, and compare versions 8.1.0 and 7.0.3. Done means getIdentityFlags() does not throw and returns a configured variant value consistently with remote evaluation.
Written by the indexing model from the issue text.
Description
Summary
Under local evaluation (enableLocalEvaluation: true), evaluating a multivariate flag fails.
We observe two different behaviours depending on the SDK version, against the same environment:
flagsmith-nodejs |
Result |
|---|---|
| 8.1.0 (latest) | getIdentityFlags() throws TypeError: Do not know how to serialize a BigInt |
| 7.0.3 | No throw, but the flag resolves to a null value instead of one of the multivariate variant values — even though enabled is true and the segment matches |
Remote evaluation (enableLocalEvaluation: false) resolves the variant correctly in both versions, so this is specific to the local-evaluation engine.
This may be related to #267 (same mapIdentityOverridesToSegments / local-evaluation path), but the trigger and symptom are different, so we're reporting it separately.
Environment
flagsmith-nodejs8.1.0and7.0.3- Node.js v22.13.1
- Server-side SDK key, Edge API (
https://edge.api.flagsmith.com/api/v1/) enableLocalEvaluation: true,environmentRefreshIntervalSeconds: 60
Steps to reproduce
- Create a MULTIVARIATE flag with a weighted split (e.g. 33/34/33 across three options).
- Add a segment override for that flag.
- Ensure the environment also contains at least one identity override entry.
- With
enableLocalEvaluation: true, call:await flagsmith.getIdentityFlags(identifier, { currency: 'EUR', domain: 'https://www.example.com' });
The environment additionally contains several identity_overrides entries (5 in our case, identifiers redacted).
Actual behaviour
8.1.0 — stack trace:
TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at mapIdentityOverridesToSegments (flagsmith-engine/evaluation/evaluationContext/mappers.js:130:81)
at mapEnvironmentModelToEvaluationContext (flagsmith-engine/evaluation/evaluationContext/mappers.js:69:36)
at getEvaluationContext (flagsmith-engine/evaluation/evaluationContext/mappers.js:9:32)
at Flagsmith.getIdentityFlagsFromDocument (sdk/index.js:385:63)
at async Flagsmith.getIdentityFlags (sdk/index.js:192:24)
The error is thrown while building the evaluation context, before any specific flag is read, so
it fails getIdentityFlags() for every flag in the environment — not only the multivariate one.
7.0.3: no error, but the value of the multivariate flag comes back as null (the override's
base feature_state_value) instead of one of the configured variant values.
Expected behaviour
getIdentityFlags() should resolve the multivariate flag to one of its variant values (the deterministic percentage split), matching what remote evaluation returns, without throwing.
Thank you in advance for your help
- Dominant language
- TypeScript
- Stars
- 30
- Forks
- 30
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flagsmith/flagsmith-nodejs-client
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Flagsmith/flagsmith-nodejs-client#332 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 Under an hour Newbie friendliness 85/100
Flagsmith/flagsmith-nodejs-client#304 ·
Maintainers usually reply within 2 days
-
Experimentation events are dropped when they're tracked faster than one batch round-trip, and the buffer can't be raised past Flagsmith's 2 MiB batch limitPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Flagsmith/flagsmith-nodejs-client#330 ·
Maintainers usually reply within 2 days
-
Dependency DashboardOpen
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Flagsmith/flagsmith-nodejs-client#286 ·
Maintainers usually reply within 2 days
-
[sdk/local-evaluation] Duplicate identity override entries silently drop feature overridesPossibly taken @xolott-ark claimed this 203 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Flagsmith/flagsmith-nodejs-client#267 · 5 comments ·
Maintainers usually reply within 2 days
All issues in Flagsmith/flagsmith-nodejs-client
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
earendil-works/pi#12615 ·
Maintainers usually reply within 1 day
-
My Caps shows "Shared" on private Caps that were never sharedPossibly taken @AksharP5 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CapSoftware/Cap#4569 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OHDSI/Data2Evidence#3749 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
bug from-app needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
nightly-labs/openbot#17688 ·
Maintainers usually reply within 1 day