From a7d9165a7ca1e6b9e7fdeb6fba61ebf335c6a0d3 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 10 Sep 2024 10:49:50 +0300 Subject: Handle case when result is empty when sanitizing json-ld result. Signed-off-by: Munyoki Kilyungi --- gn3/db/rdf/wiki.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gn3/db/rdf') diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py index 03945ec..7d0b3f3 100644 --- a/gn3/db/rdf/wiki.py +++ b/gn3/db/rdf/wiki.py @@ -31,8 +31,10 @@ WIKI_CONTEXT = BASE_CONTEXT | { } -def __sanitize_result(result: dict): +def __sanitize_result(result: dict) -> dict: """Make sure `categories` and `pubmed_ids` are always arrays""" + if not result: + return {} categories = result.get("categories") if isinstance(categories, str): result["categories"] = [categories] if categories else [] -- cgit v1.2.3