diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ae3c0da..f8c9f514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## [Unreleased] +### Fixed +- Client crash in case of Client ID saving error, by @HardNorth + +## [5.3.1] ### Added - `MAX_LOG_BATCH_SIZE` constant into `log_manager` module, by @HardNorth ### Fixed diff --git a/reportportal_client/services/client_id.py b/reportportal_client/services/client_id.py index b658de97..c0805143 100644 --- a/reportportal_client/services/client_id.py +++ b/reportportal_client/services/client_id.py @@ -15,6 +15,7 @@ import configparser import io +import logging import os from uuid import uuid4 @@ -24,6 +25,10 @@ RP_PROPERTIES_FILE_PATH +logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) + + class __NoSectionConfigParser(configparser.ConfigParser): DEFAULT_SECTION = 'DEFAULT' @@ -77,5 +82,9 @@ def get_client_id(): client_id = _read_client_id() if not client_id: client_id = str(uuid4()) - _store_client_id(client_id) + try: + _store_client_id(client_id) + except (PermissionError, IOError) as error: + logger.exception('[%s] Unknown exception has occurred. ' + 'Skipping client ID saving.', error) return client_id diff --git a/setup.py b/setup.py index 1660edf6..c05d7086 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages -__version__ = '5.3.1' +__version__ = '5.3.2' TYPE_STUBS = ['*.pyi'] diff --git a/tests/test_client.py b/tests/test_client.py index f3f1ef9b..a0272b38 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -123,7 +123,7 @@ def get_call(*args, **kwargs): @mock.patch('reportportal_client.client.getenv') @mock.patch('reportportal_client.client.send_event') -def test_skip_analytics(send_event, getenv): +def test_skip_statistics(send_event, getenv): getenv.return_value = '1' client = RPClient('http://endpoint', 'project', 'token') client.session = mock.Mock() @@ -133,7 +133,7 @@ def test_skip_analytics(send_event, getenv): @mock.patch('reportportal_client.client.getenv') @mock.patch('reportportal_client.client.send_event') -def test_analytics(send_event, getenv): +def test_statistics(send_event, getenv): getenv.return_value = '' client = RPClient('http://endpoint', 'project', 'token') client.session = mock.Mock()