Skip to content

Commit 91cfa69

Browse files
[AI-FSSDK] [FSSDK-12418] Remove experiment type validation from config parsing (#402)
* [AI-FSSDK] [FSSDK-12418] Remove experiment type validation from config parsing * [FSSDK-12423] dead code removal --------- Co-authored-by: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com>
1 parent 1099ba7 commit 91cfa69

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

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>();

OptimizelySDK/Entity/Experiment.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ public class Experiment : ExperimentCore
2323
{
2424
private const string MUTEX_GROUP_POLICY = "random";
2525

26-
public const string EXPERIMENT_TYPE_AB = "ab";
27-
public const string EXPERIMENT_TYPE_MAB = "mab";
28-
public const string EXPERIMENT_TYPE_CMAB = "cmab";
29-
public const string EXPERIMENT_TYPE_TD = "td";
3026
public const string EXPERIMENT_TYPE_FR = "fr";
3127

3228
/// <summary>

0 commit comments

Comments
 (0)