Skip to content

Commit f2b3bf4

Browse files
[AI-FSSDK] [FSSDK-12418] Remove experiment type validation from config parsing
1 parent 1099ba7 commit f2b3bf4

2 files changed

Lines changed: 13 additions & 18 deletions

File tree

OptimizelySDK.Tests/ProjectConfigTest.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,19 @@ public void TestTypeFieldParsedCorrectly()
17361736
Assert.AreEqual("fr", rolloutExperiment.Type);
17371737
}
17381738

1739+
[Test]
1740+
public void TestUnknownExperimentTypeAccepted()
1741+
{
1742+
var datafile = BuildFeatureRolloutDatafile(experimentType: "new_unknown_type");
1743+
var config = DatafileProjectConfig.Create(datafile, LoggerMock.Object,
1744+
ErrorHandlerMock.Object);
1745+
1746+
Assert.IsNotNull(config);
1747+
var experiment = config.GetExperimentFromKey("rollout_experiment");
1748+
Assert.IsNotNull(experiment);
1749+
Assert.AreEqual("new_unknown_type", experiment.Type);
1750+
}
1751+
17391752
#endregion
17401753
}
17411754
}

OptimizelySDK/Config/DatafileProjectConfig.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -375,26 +375,8 @@ private void Initialize()
375375
}
376376
}
377377

378-
var validExperimentTypes = new HashSet<string>
379-
{
380-
Experiment.EXPERIMENT_TYPE_AB,
381-
Experiment.EXPERIMENT_TYPE_MAB,
382-
Experiment.EXPERIMENT_TYPE_CMAB,
383-
Experiment.EXPERIMENT_TYPE_TD,
384-
Experiment.EXPERIMENT_TYPE_FR,
385-
};
386-
387378
foreach (var experiment in _ExperimentIdMap.Values)
388379
{
389-
if (experiment.Type != null && !validExperimentTypes.Contains(experiment.Type))
390-
{
391-
Logger.Log(LogLevel.ERROR,
392-
$@"Experiment ""{experiment.Key}"" has invalid type ""{experiment.Type}"".");
393-
ErrorHandler.HandleError(
394-
new InvalidExperimentException(
395-
$"Invalid experiment type: {experiment.Type}"));
396-
}
397-
398380
_VariationKeyMap[experiment.Key] = new Dictionary<string, Variation>();
399381
_VariationIdMap[experiment.Key] = new Dictionary<string, Variation>();
400382
_VariationIdMapByExperimentId[experiment.Id] = new Dictionary<string, Variation>();

0 commit comments

Comments
 (0)