diff --git a/backend/python/app/services/graph_db/arango/arango.py b/backend/python/app/services/graph_db/arango/arango.py index d9e408d05e..c0a1a5c0ca 100644 --- a/backend/python/app/services/graph_db/arango/arango.py +++ b/backend/python/app/services/graph_db/arango/arango.py @@ -388,24 +388,21 @@ async def batch_upsert_documents(self, collection_name: str, documents: List[Dic async def get_document(self, collection_name: str, document_key: str) -> Optional[Dict[str, Any]]: """Get a document by key from a collection""" + db = self.db + if not db: + self.logger.error("Database not connected") + return None try: - if not self.db: - self.logger.error("Database not connected") - return None - - collection = self.db.collection(collection_name) - - try: - document = collection.get(document_key) - return document - except Exception: - # Document not found - return None - + collection = db.collection(collection_name) + document = collection.get(document_key) except Exception as e: - self.logger.error(f"Failed to get document {document_key} from {collection_name}: {e}") + # Document not found or other collection/db error + # We want to log only on extreme failures (outer exception), as in the original; + # On not-found or other inner exceptions, just return None. return None + return document + async def delete_document(self, collection_name: str, document_key: str) -> bool: """Delete a document by key from a collection""" try: