From f22a7806793d62bb39f5f8f4e050ab2a3e7ad4d6 Mon Sep 17 00:00:00 2001 From: Sushanth012 <146400678+Sushanth012@users.noreply.github.com> Date: Sun, 30 Aug 2026 13:07:34 -0700 Subject: [PATCH] Don't crash when an extracted identity value isn't a string (#3039) --- maigret/utils.py | 2 +- tests/test_utils.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/maigret/utils.py b/maigret/utils.py index 7b215ee2..959ba58f 100644 --- a/maigret/utils.py +++ b/maigret/utils.py @@ -96,7 +96,7 @@ def get_dict_ascii_tree(items, prepend="", new_line=True): if isinstance(item, tuple): field_name, field_value = item - if field_value.startswith("['"): + if isinstance(field_value, str) and field_value.startswith("['"): is_last_item = num == len(items) - 1 prepend_symbols = " " * 3 if is_last_item else f" {skip_result} " data = ascii_data_display(field_value) diff --git a/tests/test_utils.py b/tests/test_utils.py index b606f03a..b2f0528a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -191,6 +191,10 @@ def test_get_dict_ascii_tree(): ) +def test_get_dict_ascii_tree_handles_non_string_values(): + assert get_dict_ascii_tree([('uid', 42)], new_line=False) == '└─uid: 42' + + def test_get_match_ratio(): fun = get_match_ratio(["test", "maigret", "username"])