stanford-oval/storm · error · ValueError

Qdrant client is not initialized.

Error message

Qdrant client is not initialized.

What it means

VectorRM._check_collection verifies self.client exists before querying collection_exists. The client is only assigned inside init_online_vector_db or init_offline_vector_db, so if _check_collection runs before those methods, self.client is still None (its __init__ default) and a ValueError is raised.

Source

Thrown at knowledge_storm/rm.py:235

        encode_kwargs = {"normalize_embeddings": True}
        self.model = HuggingFaceEmbeddings(
            model_name=embedding_model,
            model_kwargs=model_kwargs,
            encode_kwargs=encode_kwargs,
        )

        self.collection_name = collection_name
        self.client = None
        self.qdrant = None

    def _check_collection(self):
        from langchain_qdrant import Qdrant

        """
        Check if the Qdrant collection exists and create it if it does not.
        """
        if self.client is None:
            raise ValueError("Qdrant client is not initialized.")
        if self.client.collection_exists(collection_name=f"{self.collection_name}"):
            print(
                f"Collection {self.collection_name} exists. Loading the collection..."
            )
            self.qdrant = Qdrant(
                client=self.client,
                collection_name=self.collection_name,
                embeddings=self.model,
            )
        else:
            raise ValueError(
                f"Collection {self.collection_name} does not exist. Please create the collection first."
            )

    def init_online_vector_db(self, url: str, api_key: str):
        from qdrant_client import QdrantClient

        """

View on GitHub (pinned to fb951af774)

Solutions

  1. Initialize the client first via rm.init_online_vector_db(url, api_key) or rm.init_offline_vector_db(path) before any other operation
  2. If subclassing, ensure the overridden init methods assign self.client = QdrantClient(...)
  3. Do not call the private _check_collection yourself; let the init methods do it

Example fix

// before
rm = VectorRM(collection_name='docs', source='offline', vector_store_path='./qdrant', embedding_model='...')
rm._check_collection()  # client is None
// after
rm = VectorRM(...)
rm.init_offline_vector_db('./qdrant')  # sets self.client and runs _check_collection
Defensive patterns

Strategy: validation

Validate before calling

rm = VectorRM(collection_name='docs', source='offline', vector_store_path='./qdrant', embedding_model=MODEL)
assert rm.client is not None or True  # client is set only after init
rm.init_offline_vector_db('./qdrant')  # this sets self.client
assert rm.client is not None and rm.qdrant is not None

Type guard

def vectorrm_ready(rm) -> bool:
    return getattr(rm, 'client', None) is not None and getattr(rm, 'qdrant', None) is not None

Try / catch

try:
    rm.init_offline_vector_db('./qdrant')
except ValueError as e:
    if 'not initialized' in str(e):
        raise SystemExit('Initialize client via init_online/offline_vector_db first')
    raise

Prevention

When it happens

Trigger: Calling rm._check_collection() directly, or a code path where init_online_vector_db/init_offline_vector_db raised or was skipped (e.g. caught exception) before _check_collection is invoked; misordered initialization in a subclass override.

Common situations: Subclassing VectorRM and overriding init methods without setting self.client; swallowing the exception from init_online_vector_db and continuing; calling private internals directly in tests.

Related errors


AI-assisted analysis of stanford-oval/storm@fb951af774 (2026-08-28). Data as JSON: /api/errors/0a68392b8ee08177. Report an issue: GitHub.