From 3c77c30e33ffc7b01e6a280ec3509f08e4ccc2ca Mon Sep 17 00:00:00 2001 From: Ovler Date: Wed, 20 Nov 2024 03:58:56 -0500 Subject: [PATCH] fix: add error handling for invalid total items in collection retrieval --- src/ia_collection_analyzer/iahelper.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ia_collection_analyzer/iahelper.py b/src/ia_collection_analyzer/iahelper.py index 8be949d8..33b814b7 100644 --- a/src/ia_collection_analyzer/iahelper.py +++ b/src/ia_collection_analyzer/iahelper.py @@ -67,6 +67,12 @@ def get_collection(collection_id, progress_hook=None) -> list: ) collection = [] total_items = search.num_found + try: + total_items = int(search.num_found) + except ValueError: + total_items = 0 + logger.error(f"Failed to get total items for {collection_id}: search.num_found={search.num_found}") + return [] if progress_hook: progress_hook(0, total_items) for result in tqdm(