diff --git a/splitio/input_validator.py b/splitio/input_validator.py index 87c56ee5..a2f664aa 100644 --- a/splitio/input_validator.py +++ b/splitio/input_validator.py @@ -298,7 +298,8 @@ def validate_features_get_treatments(features): if not isinstance(features, list): _LOGGER.error('get_treatments: features must be a list.') return None - filtered_features = set(filter(lambda x: x is not None, features)) + filtered_features = set(filter(lambda x: x is not None and + _check_is_string(x, 'feature_name', 'get_treatments'), features)) if len(filtered_features) == 0: _LOGGER.warning('get_treatments: features is an empty list or has None values.') return filtered_features diff --git a/splitio/tests/test_get_treatments.py b/splitio/tests/test_get_treatments.py index abe1e2ab..0f4a67fb 100644 --- a/splitio/tests/test_get_treatments.py +++ b/splitio/tests/test_get_treatments.py @@ -91,3 +91,15 @@ def test_client_with_valid_none_and_repeated_features_and_valid_key(self): self.assertEqual(results['some_feature'], 'control') self.assertEqual(results['some_feature_2'], 'control') self.assertEqual(results['get_treatments_test'], 'on') + + def test_client_with_valid_none_invalid_and_repeated_features_and_valid_key(self): + features = ['some_feature', 'get_treatments_test', 'some_feature_2', + 'some_feature', 'get_treatments_test', None, 'valid', + True, [], True] + results = self._split.get_treatments('valid', features) + self.assertIn('some_feature', results) + self.assertIn('some_feature_2', results) + self.assertIn('get_treatments_test', results) + self.assertEqual(results['some_feature'], 'control') + self.assertEqual(results['some_feature_2'], 'control') + self.assertEqual(results['get_treatments_test'], 'on') diff --git a/splitio/tests/test_input_validator.py b/splitio/tests/test_input_validator.py index e08a8eb6..61a858e7 100644 --- a/splitio/tests/test_input_validator.py +++ b/splitio/tests/test_input_validator.py @@ -484,3 +484,8 @@ def test_get_treatments_with_none_features(self): self.logger_warning \ .assert_called_once_with("get_treatments: features is an empty " "list or has None values.") + + def test_get_treatments_with_invalid_type_of_features(self): + self.assertEqual({}, self.client.get_treatments("some_key", [True])) + self.logger_error \ + .assert_called_once_with("get_treatments: feature_name True has to be of type string.") diff --git a/splitio/version.py b/splitio/version.py index c5099442..32660477 100644 --- a/splitio/version.py +++ b/splitio/version.py @@ -1 +1 @@ -__version__ = '6.2.0-rc1' +__version__ = '6.2.0-rc2'