Skip to content

Commit e37ef04

Browse files
committed
fix(settings_file): logging for invalid settings file when fetched from server
1 parent caba67c commit e37ef04

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.46.1] - 2023-06-08
8+
9+
### Changed
10+
11+
- Print `settings-file` in the error log in case of `get_and_update_settings_file` API fails to fetch correct settings
12+
713
## [1.46.0] - 2023-06-06
814

915
### Added

tests/core/test_mutually_exclusive_newimpl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_traffic_weightage_campaigns(self):
7676

7777
# remove priority from settings file and initialize local vwo instance (so that logic flows to traffic weightage)
7878
new_meg_settings_without_p = new_meg_settings
79-
del new_meg_settings_without_p["groups"]["1"]["p"]
79+
new_meg_settings_without_p["groups"]["1"].pop("p", None)
8080
vwo_instance = vwo.launch(
8181
json.dumps(new_meg_settings_without_p),
8282
log_level=TEST_LOG_LEVEL,

vwo/enums/log_message_enum.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ class ERROR_MESSAGES:
180180
CONNECTION_ERROR = "({file}): HTTP Connection - {reason}. Error - {err}"
181181

182182
BATCH_EVENT_LIMIT_EXCEEDED = "({file}): Impression event - {end_point} failed due to exceeding payload size. Parameter events_per_request in batch_events config in launch API has value:{events_per_request} for accountId:{account_id}. Please read the official documentation for knowing the size limits."
183-
INVALID_SETTINGS_FILE = (
184-
"({file}): [API_NAME] settings_file fetched is not proper for the account_id: {account_id}."
185-
)
183+
INVALID_SETTINGS_FILE = "({file}): [API_NAME] settings_file fetched is not proper for the account_id: {account_id}, settings_file: {settings_file}"
186184

187185
EVENT_BATCHING_NOT_OBJECT = "({file}): Batch event settings are not of type object"
188186
EVENT_BATCHING_INSUFFICIENT = (

vwo/services/settings_file_manager.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525

2626

2727
class SettingsFileManager(object):
28-
""" VWO settings_file manager """
28+
"""VWO settings_file manager"""
2929

3030
def __init__(self, settings_file):
31-
""" Init method to load and set vwo object with settings_file data.
31+
"""Init method to load and set vwo object with settings_file data.
3232
3333
Args:
3434
settings_file (json_string): stringified json representing the vwo settings_file.
@@ -38,20 +38,20 @@ def __init__(self, settings_file):
3838

3939
# PUBLIC METHODS
4040
def process_settings_file(self):
41-
""" Processes the settings_file, assigns variation allocation range """
41+
"""Processes the settings_file, assigns variation allocation range"""
4242

4343
settings_file = self.settings_file
4444
for campaign in settings_file.get("campaigns"):
4545
campaign_util.set_variation_allocation(campaign)
4646
self.logger.log(LogLevelEnum.DEBUG, LogMessageEnum.DEBUG_MESSAGES.SETTINGS_FILE_PROCESSED.format(file=FILE))
4747

4848
def get_settings_file(self):
49-
""" Retrieves settings file """
49+
"""Retrieves settings file"""
5050

5151
return self.settings_file
5252

5353
def get_settings_file_string(self):
54-
""" Retrieves stringified json representing the settings_file """
54+
"""Retrieves stringified json representing the settings_file"""
5555

5656
return self.settings_file_string
5757

@@ -74,7 +74,9 @@ def get_and_update_settings_file(self, account_id, sdk_key, is_via_webhook):
7474
if not validate_util.is_valid_settings_file(latest_settings_file):
7575
self.logger.log(
7676
LogLevelEnum.ERROR,
77-
LogMessageEnum.ERROR_MESSAGES.INVALID_SETTINGS_FILE.format(file=FILE, account_id=account_id),
77+
LogMessageEnum.ERROR_MESSAGES.INVALID_SETTINGS_FILE.format(
78+
file=FILE, account_id=account_id, settings_file=latest_settings_file
79+
),
7880
)
7981
return False
8082

@@ -86,7 +88,7 @@ def get_and_update_settings_file(self, account_id, sdk_key, is_via_webhook):
8688
return True
8789

8890
def update_settings_file(self, settings_file):
89-
""" Update the settings_file on the instance so that latest settings could be used
91+
"""Update the settings_file on the instance so that latest settings could be used
9092
from next hit onwards
9193
9294
Args:

0 commit comments

Comments
 (0)