From 961fc6558ccb6aab9a1aacdd1b4dd3d47092dbb6 Mon Sep 17 00:00:00 2001 From: "Mark A. Miller" Date: Tue, 14 Jan 2025 10:25:20 -0500 Subject: [PATCH] do not assume presensce of results[0] --- sample_annotator/clients/gold_client.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sample_annotator/clients/gold_client.py b/sample_annotator/clients/gold_client.py index c91c16a..2b6148f 100644 --- a/sample_annotator/clients/gold_client.py +++ b/sample_annotator/clients/gold_client.py @@ -159,6 +159,11 @@ def fetch_study(self, id: str, include_biosamples=False) -> StudyDict: id = self._normalize_id(id) logging.info(f"Fetching study: {id}") results = self._call("studies", {"studyGoldId": id}) + + if not results: + logging.warning(f"No study found for ID: {id}") + return {} # Or handle differently depending on your needs + study = results[0] if include_biosamples: study["biosamples"] = self.fetch_biosamples_by_study(id)