Skip to content

Commit eb99cbd

Browse files
Handle null values in /splitChanges response for sets, ff.d, and rbs.d fields
AI-Session-Id: 616e2b0b-7059-4a31-b636-080938576336 AI-Tool: claude-code AI-Model: unknown
1 parent ed063c8 commit eb99cbd

12 files changed

Lines changed: 40 additions & 23 deletions

File tree

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.12.1 (April 28, 2026)
2+
- Updated internal modules to handle `null` values from `/splitChanges` response.
3+
14
2.12.0 (February 24, 2026)
25
- Added support for ioredis v5 (Related to issue https://github.com/splitio/javascript-commons/issues/471).
36

package-lock.json

Lines changed: 18 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-commons",
3-
"version": "2.12.0",
3+
"version": "2.12.1",
44
"description": "Split JavaScript SDK common components",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",

src/dtos/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ export interface ISplit {
232232
trafficAllocationSeed?: number
233233
configurations?: {
234234
[treatmentName: string]: string
235-
},
236-
sets?: string[],
235+
} | null,
236+
sets?: string[] | null,
237237
impressionsDisabled?: boolean
238238
}
239239

@@ -245,12 +245,12 @@ export interface ISplitChangesResponse {
245245
ff?: {
246246
t: number,
247247
s?: number,
248-
d: ISplit[]
248+
d?: ISplit[] | null,
249249
},
250250
rbs?: {
251251
t: number,
252252
s?: number,
253-
d: IRBSegment[]
253+
d?: IRBSegment[] | null,
254254
}
255255
}
256256

src/storages/inLocalStorage/SplitsCacheInLocal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
205205
});
206206
}
207207

208-
private removeFromFlagSets(featureFlagName: string, flagSets?: string[]) {
208+
private removeFromFlagSets(featureFlagName: string, flagSets?: string[] | null) {
209209
if (!flagSets) return;
210210

211211
flagSets.forEach(flagSet => {

src/storages/inMemory/SplitsCacheInMemory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
114114
});
115115
}
116116

117-
private removeFromFlagSets(featureFlagName: string, flagSets: string[] | undefined) {
117+
private removeFromFlagSets(featureFlagName: string, flagSets?: string[] | null) {
118118
if (!flagSets) return;
119119
flagSets.forEach(flagSet => {
120120
this.removeNames(flagSet, featureFlagName);

src/storages/inRedis/SplitsCacheInRedis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
5959
return this.redis.incr(ttKey);
6060
}
6161

62-
private _updateFlagSets(featureFlagName: string, flagSetsOfRemovedFlag?: string[], flagSetsOfAddedFlag?: string[]) {
62+
private _updateFlagSets(featureFlagName: string, flagSetsOfRemovedFlag?: string[] | null, flagSetsOfAddedFlag?: string[] | null) {
6363
const removeFromFlagSets = returnDifference(flagSetsOfRemovedFlag, flagSetsOfAddedFlag);
6464

6565
let addToFlagSets = returnDifference(flagSetsOfAddedFlag, flagSetsOfRemovedFlag);

src/storages/pluggable/SplitsCachePluggable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class SplitsCachePluggable extends AbstractSplitsCacheAsync {
4343
return this.wrapper.incr(ttKey);
4444
}
4545

46-
private _updateFlagSets(featureFlagName: string, flagSetsOfRemovedFlag?: string[], flagSetsOfAddedFlag?: string[]) {
46+
private _updateFlagSets(featureFlagName: string, flagSetsOfRemovedFlag?: string[] | null, flagSetsOfAddedFlag?: string[] | null) {
4747
const removeFromFlagSets = returnDifference(flagSetsOfRemovedFlag, flagSetsOfAddedFlag);
4848

4949
let addToFlagSets = returnDifference(flagSetsOfAddedFlag, flagSetsOfRemovedFlag);

src/storages/setRolloutPlan.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ export function setRolloutPlan(log: ILogger, rolloutPlan: RolloutPlan, storage:
3535

3636
if (splits && ff) {
3737
splits.clear();
38-
splits.update(ff.d, [], ff.t);
38+
splits.update(ff.d || [], [], ff.t);
3939
}
4040

4141
if (rbSegments && rbs) {
4242
rbSegments.clear();
43-
rbSegments.update(rbs.d, [], rbs.t);
43+
rbSegments.update(rbs.d || [], [], rbs.t);
4444
}
4545

4646
const segmentChanges = rolloutPlan.segmentChanges;

src/sync/polling/updaters/splitChangesUpdater.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ export function splitChangesUpdaterFactory(
173173
let updatedFlags: string[] = [];
174174
let ffUpdate: MaybeThenable<boolean> = false;
175175
if (splitChanges.ff) {
176-
const { added, removed, names } = computeMutation(splitChanges.ff.d, usedSegments, splitFiltersValidation);
176+
const { added, removed, names } = computeMutation(splitChanges.ff.d || [], usedSegments, splitFiltersValidation);
177177
updatedFlags = names;
178178
log.debug(SYNC_SPLITS_UPDATE, [added.length, removed.length]);
179179
ffUpdate = splits.update(added, removed, splitChanges.ff.t);
180180
}
181181

182182
let rbsUpdate: MaybeThenable<boolean> = false;
183183
if (splitChanges.rbs) {
184-
const { added, removed } = computeMutation(splitChanges.rbs.d, usedSegments);
184+
const { added, removed } = computeMutation(splitChanges.rbs.d || [], usedSegments);
185185
log.debug(SYNC_RBS_UPDATE, [added.length, removed.length]);
186186
rbsUpdate = rbSegments.update(added, removed, splitChanges.rbs.t);
187187
}

0 commit comments

Comments
 (0)