Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/optimizely/helpers/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ module Constants
'type' => 'object'
},
'type' => {
'type' => %w[string null],
'enum' => EXPERIMENT_TYPES.values + [nil]
'type' => %w[string null]
},
'holdouts' => {
'type' => 'array'
Expand Down
33 changes: 33 additions & 0 deletions spec/config/datafile_project_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,39 @@ def build_datafile(experiments: [], rollouts: [], feature_flags: [])
expect(experiment['type']).to be_nil
end

it 'should accept experiments with unknown type values' do
datafile = build_datafile(
experiments: [
{
'id' => 'exp_unknown',
'key' => 'unknown_type_exp',
'status' => 'Running',
'forcedVariations' => {},
'layerId' => 'layer_1',
'audienceIds' => [],
'trafficAllocation' => [{'entityId' => 'var_1', 'endOfRange' => 5000}],
'variations' => [{'key' => 'var_1', 'id' => 'var_1', 'featureEnabled' => true}],
'type' => 'new_unknown_type'
}
],
feature_flags: [
{
'id' => 'flag_1',
'key' => 'test_flag',
'experimentIds' => ['exp_unknown'],
'rolloutId' => '',
'variables' => []
}
]
)

config = Optimizely::DatafileProjectConfig.new(JSON.dump(datafile), logger, error_handler)
expect(config).not_to be_nil
experiment = config.experiment_id_map['exp_unknown']
expect(experiment['type']).to eq('new_unknown_type')
expect(experiment['key']).to eq('unknown_type_exp')
end

it 'should inject everyone else variation into feature_rollout experiments' do
datafile = build_datafile(
experiments: [
Expand Down
Loading