From 7a5bf47959262f2aa28b15a3d7f75fdae99da505 Mon Sep 17 00:00:00 2001 From: cybermaggedon Date: Mon, 5 Jan 2026 16:31:26 +0000 Subject: [PATCH] Fix collection existence test logic (#597) --- .../trustgraph/librarian/collection_manager.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/trustgraph-flow/trustgraph/librarian/collection_manager.py b/trustgraph-flow/trustgraph/librarian/collection_manager.py index fffb0358..34ce1de8 100644 --- a/trustgraph-flow/trustgraph/librarian/collection_manager.py +++ b/trustgraph-flow/trustgraph/librarian/collection_manager.py @@ -109,11 +109,16 @@ class CollectionManager: response = await self.send_config_request(request) - # If collection exists, we're done - if response.values and len(response.values) > 0: + # Validate response + if not response.values or len(response.values) == 0: + raise Exception(f"Invalid response from config service when checking collection {user}/{collection}") + + # Check if collection exists (value not None means it exists) + if response.values[0].value is not None: logger.debug(f"Collection {user}/{collection} already exists") return + # Collection doesn't exist (value is None), proceed to create # Create new collection with default metadata logger.info(f"Auto-creating collection {user}/{collection}")