Skip to content

Commit 2204fcd

Browse files
[AI-FSSDK] [FSSDK-12337] Add validation for experiment type field
1 parent 8915c19 commit 2204fcd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

core-api/src/main/java/com/optimizely/ab/config/DatafileProjectConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ public DatafileProjectConfig(String accountId,
195195
allExperiments.addAll(experiments);
196196
allExperiments.addAll(aggregateGroupExperiments(groups));
197197

198+
Set<String> validExperimentTypes = new HashSet<>(Arrays.asList(
199+
Experiment.TYPE_AB, Experiment.TYPE_MAB, Experiment.TYPE_CMAB,
200+
Experiment.TYPE_TD, Experiment.TYPE_FR
201+
));
202+
for (Experiment experiment : allExperiments) {
203+
if (experiment.getType() != null && !validExperimentTypes.contains(experiment.getType())) {
204+
throw new ConfigParseException(
205+
String.format("Experiment \"%s\" has invalid type \"%s\". Valid types: %s.",
206+
experiment.getKey(), experiment.getType(), validExperimentTypes));
207+
}
208+
}
209+
198210
// Inject "everyone else" variation into feature_rollout experiments
199211
allExperiments = injectFeatureRolloutVariations(allExperiments, this.featureFlags, this.rollouts);
200212

0 commit comments

Comments
 (0)