Skip to content

Commit 15c663b

Browse files
committed
validate split names
1 parent ecb7ef6 commit 15c663b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

splitio/client/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ def get_treatment_with_config(self, key, feature, attributes=None):
109109
start = int(round(time.time() * 1000))
110110

111111
matching_key, bucketing_key = input_validator.validate_key(key)
112-
feature = input_validator.validate_feature_name(feature)
112+
feature = input_validator.validate_feature_name(
113+
feature,
114+
self.ready,
115+
self._factory._get_storage('splits') #pylint: disable=protected-access
116+
)
113117

114118
if (matching_key is None and bucketing_key is None) \
115119
or feature is None \

splitio/client/input_validator.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def validate_key(key):
252252
return matching_key_result, bucketing_key_result
253253

254254

255-
def validate_feature_name(feature_name):
255+
def validate_feature_name(feature_name, should_validate_existance, split_storage):
256256
"""
257257
Check if feature_name is valid for get_treatment.
258258
@@ -266,6 +266,16 @@ def validate_feature_name(feature_name):
266266
(not _check_is_string(feature_name, 'feature_name', operation)) or \
267267
(not _check_string_not_empty(feature_name, 'feature_name', operation)):
268268
return None
269+
270+
if should_validate_existance and split_storage.get(feature_name) is None:
271+
_LOGGER.error(
272+
"%s: you passed \"%s\" that does not exist in this environment, "
273+
"please double check what Splits exist in the web console.",
274+
operation,
275+
feature_name
276+
)
277+
return None
278+
269279
return _remove_empty_spaces(feature_name, operation)
270280

271281

0 commit comments

Comments
 (0)