Sometimes, usually soon after I created a collection, when I use client.collections.get("CollectionName") it returns None even though I specified the name correctly, the connection is successful and the collection exists.
If I run my code again then it works fine. It happens rarely but I couldn’t find a definitive answer and a definitive way of solving this issue.
Server Setup Information
Weaviate Server Version: 1.29.1
Deployment Method: Docker Image
Multi Node? Number of Running Nodes: Running locally on my machine and Weaviate Cloud instance
Thank you for the welcome and for looking into this issue.
I think there might be some confusion about my problem. The code snippet you provided wouldn’t work in my case because when client.collections.get("CollectionName") returns None, I can’t call .exists() on it - that would throw an AttributeError.
Let me clarify the issue more precisely:
The Problem:
python
# This intermittently returns None instead of the collection object
collection = client.collections.get("MyCollection")
print(collection) # Sometimes prints: None
# But running the exact same line again usually works:
collection = client.collections.get("MyCollection")
print(collection) # Now prints: <weaviate.collections.collection.Collection object>
The collection definitely exists - I can verify this through the Weaviate console and other API calls. The issue seems to be a race condition or timing problem where the get() method intermittently fails to retrieve an existing collection.
Environment Details:
Weaviate Python Client: 4.11.3
Weaviate Server: 1.29.1 (local Docker) and 1.30.3 (Weaviate Cloud)
Occurs on both local and cloud deployments
Most frequent shortly after collection creation
My Questions:
Is this a known race condition in the client or server?
Should I implement retry logic as a workaround?
Is there a proper way to wait for collection availability after creation?
Would upgrading to the latest client/server versions resolve this?
The issue is rare but concerning for production reliability. Any insights would be greatly appreciated.
client.collections.get does not do any IO (eg it does NOT connect to weaviate to check if the collection exists). Looking at the code, I don’t see any possibility for this call to return None.
Thank you for the clarification. I apologize for the confusion in my previous message - I misstated the problem.
The actual issue is NOT that client.collections.get() returns None.
The real problem is that I get an error saying the collection doesn’t exist when calling client.collections.get("CollectionName"), even though:
The collection definitely exists
The same code worked moments before
Running the identical code again immediately after the error works perfectly
What actually happens:
python
# This occasionally throws an error like "Collection 'MyCollection' does not exist"
collection = client.collections.get("MyCollection")
# But running the exact same line again works fine
collection = client.collections.get("MyCollection") # Works now
This has happened only twice in 3 months of heavy Weaviate usage, making it very difficult to reproduce or debug. It seems to occur most often shortly after collection creation.