Skip to content

Commit 3409f8e

Browse files
[AI-FSSDK] [FSSDK-12418] Remove experiment type validation from config parsing
1 parent 91fb9a5 commit 3409f8e

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

lib/optimizely/helpers/constants.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ module Constants
214214
'type' => 'object'
215215
},
216216
'type' => {
217-
'type' => %w[string null],
218-
'enum' => EXPERIMENT_TYPES.values + [nil]
217+
'type' => %w[string null]
219218
},
220219
'holdouts' => {
221220
'type' => 'array'

spec/config/datafile_project_config_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,39 @@ def build_datafile(experiments: [], rollouts: [], feature_flags: [])
18801880
expect(experiment['type']).to be_nil
18811881
end
18821882

1883+
it 'should accept experiments with unknown type values' do
1884+
datafile = build_datafile(
1885+
experiments: [
1886+
{
1887+
'id' => 'exp_unknown',
1888+
'key' => 'unknown_type_exp',
1889+
'status' => 'Running',
1890+
'forcedVariations' => {},
1891+
'layerId' => 'layer_1',
1892+
'audienceIds' => [],
1893+
'trafficAllocation' => [{'entityId' => 'var_1', 'endOfRange' => 5000}],
1894+
'variations' => [{'key' => 'var_1', 'id' => 'var_1', 'featureEnabled' => true}],
1895+
'type' => 'new_unknown_type'
1896+
}
1897+
],
1898+
feature_flags: [
1899+
{
1900+
'id' => 'flag_1',
1901+
'key' => 'test_flag',
1902+
'experimentIds' => ['exp_unknown'],
1903+
'rolloutId' => '',
1904+
'variables' => []
1905+
}
1906+
]
1907+
)
1908+
1909+
config = Optimizely::DatafileProjectConfig.new(JSON.dump(datafile), logger, error_handler)
1910+
expect(config).not_to be_nil
1911+
experiment = config.experiment_id_map['exp_unknown']
1912+
expect(experiment['type']).to eq('new_unknown_type')
1913+
expect(experiment['key']).to eq('unknown_type_exp')
1914+
end
1915+
18831916
it 'should inject everyone else variation into feature_rollout experiments' do
18841917
datafile = build_datafile(
18851918
experiments: [

0 commit comments

Comments
 (0)