@@ -41,7 +41,7 @@ def _item(**overrides):
4141def test_known_positions_are_rendered_as_call_sites () -> None :
4242 # Arrange
4343 item = _item (
44- callSites = [{"filePath " : "src/svc.py" , "line" : 17 }],
44+ callSites = [{"position " : "src/svc.py:17" }],
4545 callSiteCount = 1 ,
4646 )
4747
@@ -56,8 +56,8 @@ def test_confidence_is_shown_only_when_the_position_is_approximate() -> None:
5656 # Arrange
5757 item = _item (
5858 callSites = [
59- {"filePath " : "src/svc.py" , "line" : 17 },
60- {"filePath " : "src/svc.py" , "line" : 88 , "confidence" : 0.6 },
59+ {"position " : "src/svc.py:17" },
60+ {"position " : "src/svc.py:88" , "confidence" : 0.6 },
6161 ],
6262 callSiteCount = 2 ,
6363 )
@@ -73,7 +73,7 @@ def test_confidence_is_shown_only_when_the_position_is_approximate() -> None:
7373def test_a_capped_list_says_how_many_were_withheld () -> None :
7474 # Arrange
7575 item = _item (
76- callSites = [{"filePath " : "src/svc.py" , "line" : 17 }],
76+ callSites = [{"position " : "src/svc.py:17" }],
7777 callSiteCount = 4 ,
7878 )
7979
@@ -98,3 +98,20 @@ def test_an_unindexed_position_renders_nothing_at_all() -> None:
9898 # Assert
9999 assert from_missing == []
100100 assert from_empty == []
101+
102+
103+ def test_a_site_without_a_position_is_skipped_rather_than_rendered_blank () -> None :
104+ # Defensive: a malformed site from an older or partially rolled-back backend must not produce a
105+ # "called at" line pointing nowhere, which an agent would try to read.
106+ # Arrange
107+ item = _item (
108+ # The count is the pre-cap total of KNOWN positions, so a malformed entry does not raise it.
109+ callSites = [{"confidence" : 0.6 }, {"position" : "src/svc.py:17" }],
110+ callSiteCount = 1 ,
111+ )
112+
113+ # Act
114+ lines = relationships ._format_call_sites (item )
115+
116+ # Assert
117+ assert lines == [" ↪ called at src/svc.py:17" ]
0 commit comments