From 32879d23109338ee093fc2f364932d0c746c6f6d Mon Sep 17 00:00:00 2001 From: Estelle Da Date: Fri, 11 Sep 2026 16:47:02 +1000 Subject: [PATCH] Fix the outer source not found error in both Method sources and Threshold sources in creating a new score set and calibration. --- src/mavedb/lib/external_publications.py | 11 ++++++++++- src/mavedb/lib/identifiers.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mavedb/lib/external_publications.py b/src/mavedb/lib/external_publications.py index a48ff7185..96c4f8dd7 100644 --- a/src/mavedb/lib/external_publications.py +++ b/src/mavedb/lib/external_publications.py @@ -564,4 +564,13 @@ def _fetch(self, url: str, return_format: str = "json") -> Any: return [] response.raise_for_status() - return json.loads(response.text) if return_format == "json" else response.text + + if return_format == "json": + if not response.text or not response.text.strip(): + return [] + try: + return json.loads(response.text) + except json.JSONDecodeError: + return [] + + return response.text diff --git a/src/mavedb/lib/identifiers.py b/src/mavedb/lib/identifiers.py index d5bfdbd46..893442aff 100644 --- a/src/mavedb/lib/identifiers.py +++ b/src/mavedb/lib/identifiers.py @@ -216,7 +216,10 @@ async def fetch_biorxiv_article(identifier: str) -> Optional[RxivContentDetail]: Fetch an existing bioRxiv article from Rxiv """ fetch = Rxiv("https://api.biorxiv.org", "biorxiv") - articles = fetch.content_detail(identifier=identifier) + try: + articles = fetch.content_detail(identifier=identifier) + except Exception: + return None try: return articles[-1] except IndexError: @@ -228,7 +231,10 @@ async def fetch_medrxiv_article(identifier: str) -> Optional[RxivContentDetail]: Fetch an existing medRxiv article from Rxiv """ fetch = Rxiv("https://api.biorxiv.org", "medrxiv") - articles = fetch.content_detail(identifier=identifier) + try: + articles = fetch.content_detail(identifier=identifier) + except Exception: + return None try: return articles[-1] except IndexError: