mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-09 10:39:11 +02:00
fix: services research source extraction crashes on a non-dict finding (#1868)
This commit is contained in:
parent
d05900cb90
commit
1aad1db9f6
2 changed files with 17 additions and 0 deletions
|
|
@ -186,6 +186,8 @@ class ResearchHandler:
|
||||||
seen = set()
|
seen = set()
|
||||||
sources = []
|
sources = []
|
||||||
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 url
|
title = f.get("title", "") or url
|
||||||
summary = f.get("summary", "") or f.get("evidence", "")
|
summary = f.get("summary", "") or f.get("evidence", "")
|
||||||
|
|
|
||||||
15
tests/test_svc_research_sources_nondict.py
Normal file
15
tests/test_svc_research_sources_nondict.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
from services.research.research_handler import ResearchHandler
|
||||||
|
|
||||||
|
|
||||||
|
def test_extract_sources_skips_non_dict_findings():
|
||||||
|
# findings come from the DeepResearcher result list / cached JSON; a
|
||||||
|
# malformed entry (None or a bare string) made f.get crash and drop every
|
||||||
|
# real source.
|
||||||
|
findings = [
|
||||||
|
{"url": "https://a.com", "title": "A", "summary": "real analysis of the topic"},
|
||||||
|
"junk-row",
|
||||||
|
None,
|
||||||
|
{"url": "https://b.com", "summary": "more genuine detail here"},
|
||||||
|
]
|
||||||
|
out = ResearchHandler._extract_sources(findings)
|
||||||
|
assert [s["url"] for s in out] == ["https://a.com", "https://b.com"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue