Skip to content

Commit c70b591

Browse files
authored
fix no update bug (#382)
fix bug where failed streaming returns default empty {} which gets parsed as no update and do not trigger fallback on config syncs
1 parent bdfdce4 commit c70b591

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

statsig/http_worker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def get_dcs(self, on_complete: Callable, since_time=0, log_on_exception=False, i
5555
tag="download_config_specs")
5656
self._context.source_api = self.__api_for_download_config_specs
5757
if response is not None and self._is_success_code(response.status_code):
58-
on_complete(DataSource.NETWORK, self._stream_response_into_result_dict(response) or {}, None)
58+
on_complete(DataSource.NETWORK, self._stream_response_into_result_dict(response), None)
5959
return
6060
on_complete(DataSource.NETWORK, None, None)
6161

@@ -66,7 +66,7 @@ def get_dcs_fallback(self, on_complete: Callable, since_time=0, log_on_exception
6666
tag="download_config_specs")
6767
self._context.source_api = STATSIG_CDN
6868
if response is not None and self._is_success_code(response.status_code):
69-
on_complete(DataSource.STATSIG_NETWORK, self._stream_response_into_result_dict(response) or {}, None)
69+
on_complete(DataSource.STATSIG_NETWORK, self._stream_response_into_result_dict(response), None)
7070
return
7171
on_complete(DataSource.STATSIG_NETWORK, None, None)
7272

@@ -80,7 +80,7 @@ def get_id_lists(self, on_complete: Callable, log_on_exception=False, init_timeo
8080
tag="get_id_lists",
8181
)
8282
if response is not None and self._is_success_code(response.status_code):
83-
return on_complete(self._stream_response_into_result_dict(response) or {}, None)
83+
return on_complete(self._stream_response_into_result_dict(response), None)
8484
return on_complete(None, None)
8585

8686
def get_id_lists_fallback(self, on_complete: Callable, log_on_exception=False, init_timeout=None):
@@ -93,7 +93,7 @@ def get_id_lists_fallback(self, on_complete: Callable, log_on_exception=False, i
9393
tag="get_id_lists",
9494
)
9595
if response is not None and self._is_success_code(response.status_code):
96-
return on_complete(self._stream_response_into_result_dict(response) or {}, None)
96+
return on_complete(self._stream_response_into_result_dict(response), None)
9797
return on_complete(None, None)
9898

9999
def get_id_list(self, on_complete, url, headers, log_on_exception=False):

statsig/spec_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _initialize_specs(self):
154154
def _process_specs(self, specs_json, source: DataSource) -> Tuple[bool, bool]: # has update, parse success
155155
self._log_process("Processing specs...")
156156
prev_lcut = self.spec_updater.last_update_time
157-
if specs_json.get("has_updates", False) is False:
157+
if specs_json.get("has_updates") is not None and not specs_json.get("has_updates"):
158158
globals.logger.log_config_sync_update(self.spec_updater.initialized, False,
159159
self.spec_updater.last_update_time,
160160
prev_lcut,
@@ -381,6 +381,6 @@ def _get_initialize_strategy(self) -> List[DataSource]:
381381
return strategies
382382
except Exception:
383383
globals.logger.warning(
384-
"Failed to get initialization sources, fallling back to always sync from statsig network "
384+
"Failed to get initialization sources, falling back to always sync from statsig network "
385385
)
386386
return [DataSource.STATSIG_NETWORK]

tests/test_telemetry_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_initialize_timeout(self, mock_request):
9292

9393
def test_no_update_counter(self, mock_request):
9494
_network_stub.stub_request_with_value(
95-
"download_config_specs/.*", 200, {"has_updated": False})
95+
"download_config_specs/.*", 200, {"has_updates": False})
9696
ob_client = MockObservabilityClient()
9797
options = StatsigOptions(api=_network_stub.host, observability_client=ob_client, rulesets_sync_interval=0.5)
9898
statsig.initialize("secret-key", options)

0 commit comments

Comments
 (0)