Skip to content

Commit 65311d6

Browse files
committed
[FSSDK-11132] make entity validation configurable in bucketer
for cmab, we are using a dummy entityId which is not a real variation id. We need to skip entity validation for cmab experiments.
1 parent b73e364 commit 65311d6

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

lib/core/bucketer/index.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,16 @@ export const bucket = function(bucketerParams: BucketerParams): DecisionResponse
138138
]);
139139

140140
const entityId = _findBucket(bucketValue, bucketerParams.trafficAllocationConfig);
141-
if (entityId !== null) {
142-
if (!bucketerParams.variationIdMap[entityId]) {
143-
if (entityId) {
144-
bucketerParams.logger?.warn(INVALID_VARIATION_ID);
145-
decideReasons.push([INVALID_VARIATION_ID]);
146-
}
147-
return {
148-
result: null,
149-
reasons: decideReasons,
150-
};
141+
142+
if (bucketerParams.validateEntity && entityId !== null && !bucketerParams.variationIdMap[entityId]) {
143+
if (entityId) {
144+
bucketerParams.logger?.warn(INVALID_VARIATION_ID);
145+
decideReasons.push([INVALID_VARIATION_ID]);
151146
}
147+
return {
148+
result: null,
149+
reasons: decideReasons,
150+
};
152151
}
153152

154153
return {

lib/core/decision_service/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,16 @@ export class DecisionService {
594594
bucketingId: string,
595595
userId: string
596596
): BucketerParams {
597+
let validateEntity = true;
598+
597599
let trafficAllocationConfig: TrafficAllocation[] = getTrafficAllocation(configObj, experiment.id);
598600
if (experiment.cmab) {
599601
trafficAllocationConfig = [{
600602
entityId: CMAB_DUMMY_ENTITY_ID,
601603
endOfRange: experiment.cmab.trafficAllocation
602604
}];
605+
606+
validateEntity = false;
603607
}
604608

605609
return {
@@ -613,6 +617,7 @@ export class DecisionService {
613617
trafficAllocationConfig,
614618
userId,
615619
variationIdMap: configObj.variationIdMap,
620+
validateEntity,
616621
}
617622
}
618623

lib/shared_types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export interface BucketerParams {
6464
variationIdMap: { [id: string]: Variation };
6565
logger?: LoggerFacade;
6666
bucketingId: string;
67+
validateEntity?: boolean;
6768
}
6869

6970
export interface DecisionResponse<T> {

0 commit comments

Comments
 (0)