[BUG] WeaviateStorage._collection_exists reports a failed schema read as a missing collection
Required prerequisites
- I have read the documentation.
- I have searched the Issue Tracker and Discussions and this has not already been reported.
What version of camel are you using?
0.2.91a7
System information
macOS 15.7.3 (arm64), Python 3.10.7, weaviate-client 4.23.1 (also checked at 4.15.0, the declared floor)
Problem description
WeaviateStorage._collection_exists() catches bare Exception and returns False, so a 401, 403, 429, 5xx or dropped connection during the schema read is reported as "collection does not exist". _check_and_create_collection() then tries to create a collection that is already there, and the operator sees class name X already exists instead of the real error.
Scope: this only happens when the connection succeeds and the schema read fails, and only from __init__. Nothing is overwritten, because collections.create rejects an existing class.
It looks unintended: client.collections.exists() already returns True for 200, False for 404 and raises for everything else, and the Qdrant and Milvus backends in the same package have no handler here.
Reproducible example code
from unittest.mock import MagicMock, patch
from camel.storages import WeaviateStorage
client = MagicMock()
client.collections.get.return_value.config.get.side_effect = Exception("429 rate limited")
with patch.object(WeaviateStorage, "_get_connection_client", return_value=client), \
patch.object(WeaviateStorage, "_check_and_create_collection"):
storage = WeaviateStorage(vector_dim=4, collection_name="prod", connection_type="local")
print(storage._collection_exists("prod")) # False, although the collection existsA patch and tests are in #4372.
Source: camel-ai/camel