Skip to content

Commit 6d79053

Browse files
fix: update error logging format for CMAB fetch failures
1 parent 4743376 commit 6d79053

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

optimizely/decision_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _get_decision_for_cmab_experiment(
164164
except Exception as e:
165165
error_message = Errors.CMAB_FETCH_FAILED_DETAILED.format(experiment.key)
166166
if self.logger:
167-
self.logger.error(f"{error_message} - {str(e)}")
167+
self.logger.error(f"{error_message} {str(e)}")
168168
return {
169169
"error": True,
170170
"result": None,

optimizely/helpers/enums.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ class Errors:
127127
ODP_INVALID_DATA: Final = 'ODP data is not valid.'
128128
ODP_INVALID_ACTION: Final = 'ODP action is not valid (cannot be empty).'
129129
MISSING_SDK_KEY: Final = 'SDK key not provided/cannot be found in the datafile.'
130-
CMAB_FETCH_FAILED: Final = 'CMAB decision fetch failed with status: {}'
131-
INVALID_CMAB_FETCH_RESPONSE: Final = 'Invalid CMAB fetch response'
132-
CMAB_FETCH_FAILED_DETAILED: Final = 'Failed to fetch CMAB data for experiment {}'
130+
CMAB_FETCH_FAILED: Final = 'CMAB decision fetch failed with status: {}.'
131+
INVALID_CMAB_FETCH_RESPONSE: Final = 'Invalid CMAB fetch response.'
132+
CMAB_FETCH_FAILED_DETAILED: Final = 'Failed to fetch CMAB data for experiment {}.'
133133

134134

135135
class ForcedDecisionLogs:

tests/test_decision_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ def test_get_variation_cmab_experiment_deep_mock_500_error(self):
988988
self.assertIn(detailed_error_message, reasons)
989989

990990
# Verify logger was called with the specific 500 error
991-
mock_logger.error.assert_any_call(f'{detailed_error_message} - {error_message}')
991+
mock_logger.error.assert_any_call(f'{detailed_error_message} {error_message}')
992992

993993
def test_get_variation_cmab_experiment_forced_variation(self):
994994
"""Test get_variation with CMAB experiment when user has a forced variation."""

0 commit comments

Comments
 (0)