diff --git a/src/instana/options.py b/src/instana/options.py index 2bd2f4e0..dee797d7 100644 --- a/src/instana/options.py +++ b/src/instana/options.py @@ -139,6 +139,10 @@ def set_from(self, res_data: Dict[str, Any]) -> None: @param res_data: source identifiers provided as announce response @return: None """ + if not res_data or not isinstance(res_data, dict): + logger.debug(f"options.set_from: Wrong data type - {type(res_data)}") + return + if "secrets" in res_data: self.set_secrets(res_data["secrets"]) diff --git a/tests/test_options.py b/tests/test_options.py index 747f348f..025ff092 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -188,6 +188,27 @@ def test_set_from(self) -> None: assert test_standard_options.extra_http_headers == test_res_data["extraHeaders"] + def test_set_from_bool( + self, + caplog: pytest.LogCaptureFixture, + ) -> None: + caplog.set_level(logging.DEBUG, logger="instana") + caplog.clear() + + test_standard_options = StandardOptions() + test_res_data = True + test_standard_options.set_from(test_res_data) + + assert len(caplog.messages) == 1 + assert len(caplog.records) == 1 + assert ( + "options.set_from: Wrong data type - " in caplog.messages[0] + ) + + assert test_standard_options.secrets_list == ["key", "pass", "secret"] + assert test_standard_options.ignore_endpoints == [] + assert not test_standard_options.extra_http_headers + class TestServerlessOptions: @pytest.fixture(autouse=True)