Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/instana/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
21 changes: 21 additions & 0 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 - <class 'bool'>" 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)
Expand Down
Loading