client.collections.get("CollectionName") sometimes returns None even though the collection name specified correctly and the collection exists

Description

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
  • Client Language and Version: Python (v4 client)
  • Multitenancy?: No

Any additional Information

Nothing specific

Good morning @Azizjon_Kasimov,

Welcome to our community! It’s lovely to have you here with us :hugs:

I’ve run some tests on my end and wasn’t able to replicate the same behavior you’re seeing.

Could you please try the following snippet to check whether the exists() method works as expected?

col = client.collections.get("MyCollection")

print(f"Collection details: {col}")

exists = col.exists()

print(f"Collection exists: {exists}")

A couple of things to double-check:

  • Are you using the latest version of the Weaviate Python client? If not, please upgrade.
  • I recommend upgrading your Weaviate DB to latest 1.31.1 (or 1.30.7)

Please try again after updating your client and let me know how it goes!

Best regards,

Mohamed Shahin
Weaviate Support Engineer
(Ireland, UTC±00:00/+01:00)

Hi Mohamed,

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:

  1. Is this a known race condition in the client or server?
  2. Should I implement retry logic as a workaround?
  3. Is there a proper way to wait for collection availability after creation?
  4. 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.

Best regards,
Azizjon

Hey,

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.

Could you provide a full example?

Hi,

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:

  1. The collection definitely exists
  2. The same code worked moments before
  3. 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.