fix: a non-dict finding silently drops all raw research findings (#1739)
This commit is contained in:
@@ -479,6 +479,8 @@ class ResearchHandler:
|
|||||||
try:
|
try:
|
||||||
items = []
|
items = []
|
||||||
for f in findings:
|
for f in findings:
|
||||||
|
if not isinstance(f, dict):
|
||||||
|
continue
|
||||||
url = f.get("url", "")
|
url = f.get("url", "")
|
||||||
title = f.get("title", "") or "Untitled"
|
title = f.get("title", "") or "Untitled"
|
||||||
summary = f.get("summary", "")
|
summary = f.get("summary", "")
|
||||||
|
|||||||
14
tests/test_research_handler_raw_nondict.py
Normal file
14
tests/test_research_handler_raw_nondict.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from src.research_handler import ResearchHandler
|
||||||
|
|
||||||
|
|
||||||
|
def test_extract_raw_findings_skips_non_dict_without_losing_all():
|
||||||
|
# The body is wrapped in a try/except that returns [] on any error, so a
|
||||||
|
# single non-dict finding made the AttributeError from f.get swallow EVERY
|
||||||
|
# good finding (silent total data loss), not just the bad row.
|
||||||
|
findings = [
|
||||||
|
{"url": "https://a.com", "summary": "a real and useful finding here"},
|
||||||
|
"junk-row",
|
||||||
|
{"url": "https://b.com", "summary": "another genuine finding with detail"},
|
||||||
|
]
|
||||||
|
out = ResearchHandler._extract_raw_findings(findings)
|
||||||
|
assert [i["url"] for i in out] == ["https://a.com", "https://b.com"]
|
||||||
Reference in New Issue
Block a user