Skip to content

Commit 306df0d

Browse files
committed
fix: TypeError of non-dict response data from Agent announcement.
Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
1 parent 8aed64c commit 306df0d

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/instana/options.py

+4
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ def set_from(self, res_data: Dict[str, Any]) -> None:
139139
@param res_data: source identifiers provided as announce response
140140
@return: None
141141
"""
142+
if not res_data or not isinstance(res_data, dict):
143+
logger.debug(f"options.set_from: Wrong data type - {type(res_data)}")
144+
return
145+
142146
if "secrets" in res_data:
143147
self.set_secrets(res_data["secrets"])
144148

tests/test_options.py

+21
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,27 @@ def test_set_from(self) -> None:
188188

189189
assert test_standard_options.extra_http_headers == test_res_data["extraHeaders"]
190190

191+
def test_set_from_bool(
192+
self,
193+
caplog: pytest.LogCaptureFixture,
194+
) -> None:
195+
caplog.set_level(logging.DEBUG, logger="instana")
196+
caplog.clear()
197+
198+
test_standard_options = StandardOptions()
199+
test_res_data = True
200+
test_standard_options.set_from(test_res_data)
201+
202+
assert len(caplog.messages) == 1
203+
assert len(caplog.records) == 1
204+
assert (
205+
"options.set_from: Wrong data type - <class 'bool'>" in caplog.messages[0]
206+
)
207+
208+
assert test_standard_options.secrets_list == ["key", "pass", "secret"]
209+
assert test_standard_options.ignore_endpoints == []
210+
assert not test_standard_options.extra_http_headers
211+
191212

192213
class TestServerlessOptions:
193214
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)