From 969db13ff2c43421357509bbe3d5a562983ba06f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 31 May 2022 08:49:23 -0700 Subject: [PATCH] Safely return None in remote search return_first --- bookwyrm/connectors/connector_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/connectors/connector_manager.py b/bookwyrm/connectors/connector_manager.py index 5c8b43fd..af79b248 100644 --- a/bookwyrm/connectors/connector_manager.py +++ b/bookwyrm/connectors/connector_manager.py @@ -97,7 +97,7 @@ def search(query, min_confidence=0.1, return_first=False): # find the best result from all the responses and return that all_results = [r for con in results for r in con["results"]] all_results = sorted(all_results, key=lambda r: r.confidence, reverse=True) - return all_results[0] + return all_results[0] if all_results else None # failed requests will return None, so filter those out return results