diff --git a/splitio/api/client.py b/splitio/api/client.py index 5d3ef6f4..c9032e0e 100644 --- a/splitio/api/client.py +++ b/splitio/api/client.py @@ -207,7 +207,11 @@ def get(self, server, path, sdk_key, query=None, extra_headers=None): # pylint: self._record_telemetry(response.status_code, get_current_epoch_time_ms() - start) return HttpResponse(response.status_code, response.text, response.headers) - except Exception as exc: # pylint: disable=broad-except + except requests.exceptions.ChunkedEncodingError as exc: + _LOGGER.error("IncompleteRead exception detected: %s", exc) + return HttpResponse(400, "", {}) + + except Exception as exc: # pylint: disable=broad-except raise HttpClientException(_EXC_MSG.format(source='request')) from exc def post(self, server, path, sdk_key, body, query=None, extra_headers=None): # pylint: disable=too-many-arguments @@ -300,6 +304,10 @@ async def get(self, server, path, apikey, query=None, extra_headers=None): # py await self._record_telemetry(response.status, get_current_epoch_time_ms() - start) return HttpResponse(response.status, body, response.headers) + except aiohttp.ClientPayloadError as exc: + _LOGGER.error("ContentLengthError exception detected: %s", exc) + return HttpResponse(400, "", {}) + except aiohttp.ClientError as exc: # pylint: disable=broad-except raise HttpClientException(_EXC_MSG.format(source='aiohttp')) from exc diff --git a/splitio/api/splits.py b/splitio/api/splits.py index 619306a1..771100fc 100644 --- a/splitio/api/splits.py +++ b/splitio/api/splits.py @@ -89,6 +89,10 @@ def fetch_splits(self, change_number, rbs_change_number, fetch_options): self._check_last_proxy_check_timestamp(change_number) change_number = self._check_old_spec_since(change_number) + if self._spec_version == _SPEC_1_1: + fetch_options = FetchOptions(fetch_options.cache_control_headers, fetch_options.change_number, + None, fetch_options.sets, self._spec_version) + rbs_change_number = None query, extra_headers = build_fetch(change_number, fetch_options, self._metadata, rbs_change_number) response = self._client.get( 'sdk', @@ -158,6 +162,10 @@ async def fetch_splits(self, change_number, rbs_change_number, fetch_options): try: self._check_last_proxy_check_timestamp(change_number) change_number = self._check_old_spec_since(change_number) + if self._spec_version == _SPEC_1_1: + fetch_options = FetchOptions(fetch_options.cache_control_headers, fetch_options.change_number, + None, fetch_options.sets, self._spec_version) + rbs_change_number = None query, extra_headers = build_fetch(change_number, fetch_options, self._metadata, rbs_change_number) response = await self._client.get( diff --git a/splitio/models/grammar/matchers/rule_based_segment.py b/splitio/models/grammar/matchers/rule_based_segment.py index 06baf4b2..81777f0d 100644 --- a/splitio/models/grammar/matchers/rule_based_segment.py +++ b/splitio/models/grammar/matchers/rule_based_segment.py @@ -63,9 +63,12 @@ def _match_dep_rb_segments(self, excluded_rb_segments, key, attributes, context) else: excluded_segment = context['ec'].rbs_segments.get(excluded_rb_segment.name) if key in excluded_segment.excluded.get_excluded_keys(): - return False + return True if self._match_dep_rb_segments(excluded_segment.excluded.get_excluded_segments(), key, attributes, context): return True + + if self._match_conditions(excluded_segment.conditions, key, attributes, context): + return True - return self._match_conditions(excluded_segment.conditions, key, attributes, context) + return False diff --git a/splitio/version.py b/splitio/version.py index e8137101..bb552668 100644 --- a/splitio/version.py +++ b/splitio/version.py @@ -1 +1 @@ -__version__ = '10.2.0' \ No newline at end of file +__version__ = '10.3.0-rc2' \ No newline at end of file diff --git a/tests/engine/files/rule_base_segments2.json b/tests/engine/files/rule_base_segments2.json index ee356fd8..2f77ecd5 100644 --- a/tests/engine/files/rule_base_segments2.json +++ b/tests/engine/files/rule_base_segments2.json @@ -19,7 +19,7 @@ "trafficType": "user", "attribute": "email" }, - "matcherType": "START_WITH", + "matcherType": "STARTS_WITH", "negate": false, "whitelistMatcherData": { "whitelist": [ diff --git a/tests/engine/test_evaluator.py b/tests/engine/test_evaluator.py index a2937126..99f12cd7 100644 --- a/tests/engine/test_evaluator.py +++ b/tests/engine/test_evaluator.py @@ -314,7 +314,7 @@ def test_using_rbs_in_excluded(self): ctx = evaluation_facctory.context_for('bilal', ['some']) assert e.eval_with_context('bilal', 'bilal', 'some', {'email': 'bilal'}, ctx)['treatment'] == "on" ctx = evaluation_facctory.context_for('bilal2@split.io', ['some']) - assert e.eval_with_context('bilal2@split.io', 'bilal2@split.io', 'some', {'email': 'bilal2@split.io'}, ctx)['treatment'] == "on" + assert e.eval_with_context('bilal2@split.io', 'bilal2@split.io', 'some', {'email': 'bilal2@split.io'}, ctx)['treatment'] == "off" @pytest.mark.asyncio async def test_evaluate_treatment_with_rbs_in_condition_async(self): @@ -386,7 +386,7 @@ async def test_using_rbs_in_excluded_async(self): ctx = await evaluation_facctory.context_for('bilal', ['some']) assert e.eval_with_context('bilal', 'bilal', 'some', {'email': 'bilal'}, ctx)['treatment'] == "on" ctx = await evaluation_facctory.context_for('bilal2@split.io', ['some']) - assert e.eval_with_context('bilal2@split.io', 'bilal2@split.io', 'some', {'email': 'bilal2@split.io'}, ctx)['treatment'] == "on" + assert e.eval_with_context('bilal2@split.io', 'bilal2@split.io', 'some', {'email': 'bilal2@split.io'}, ctx)['treatment'] == "off" class EvaluationDataFactoryTests(object): """Test evaluation factory class."""