{"record":{"id":"72eaa22798c29ab6","repo":"stanford-oval/storm","slug":"qdrant-client-is-not-initialized-72eaa2","errorCode":null,"errorMessage":"Qdrant client is not initialized.","messagePattern":"Qdrant client is not initialized\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"knowledge_storm/utils.py","lineNumber":77,"sourceCode":"\nclass QdrantVectorStoreManager:\n    \"\"\"\n    Helper class for managing the Qdrant vector store, can be used with `VectorRM` in rm.py.\n\n    Before you initialize `VectorRM`, call `create_or_update_vector_store` to create or update the vector store.\n    Once you have the vector store, you can initialize `VectorRM` with the vector store path or the Qdrant server URL.\n    \"\"\"\n\n    @staticmethod\n    def _check_create_collection(\n        client: \"QdrantClient\", collection_name: str, model: \"HuggingFaceEmbeddings\"\n    ):\n        from langchain_qdrant import Qdrant\n        from qdrant_client import models\n\n        \"\"\"Check if the Qdrant collection exists and create it if it does not.\"\"\"\n        if client is None:\n            raise ValueError(\"Qdrant client is not initialized.\")\n        if client.collection_exists(collection_name=f\"{collection_name}\"):\n            print(f\"Collection {collection_name} exists. Loading the collection...\")\n            return Qdrant(\n                client=client,\n                collection_name=collection_name,\n                embeddings=model,\n            )\n        else:\n            print(\n                f\"Collection {collection_name} does not exist. Creating the collection...\"\n            )\n            # create the collection\n            client.create_collection(\n                collection_name=f\"{collection_name}\",\n                vectors_config=models.VectorParams(\n                    size=1024, distance=models.Distance.COSINE\n                ),\n            )","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/stanford-oval/storm/blob/fb951af7744dab086e34962e9bc6fe878e145f83/knowledge_storm/utils.py#L59-L95","documentation":"Raised by QdrantVectorStoreManager._check_create_collection when the qdrant_client `client` argument is None. The helper assumes it is always handed a live client (created by _init_online_vector_db or _init_offline_vector_db); a None client means initialization upstream failed or the method was called directly without a client.","triggerScenarios":"Calling _check_create_collection(client=None, ...) directly, or via create_or_update_vector_store with an online_mode path where QdrantClient construction failed but None was propagated. Normal callers (_init_online_vector_db, _init_offline_vector_db) build the client first, so this mainly fires on direct/misuse calls.","commonSituations":"Developer calls the private static helper directly in custom code; a modified fork of utils.py passes None on connection failure; type confusion where a variable holding None is passed instead of the client object.","solutions":["Don't call _check_create_collection directly; use QdrantVectorStoreManager.create_or_update_vector_store(...) or _init_online_vector_db/_init_offline_vector_db which construct the client","If calling directly, construct and pass a real client: from qdrant_client import QdrantClient; client = QdrantClient(url=..., api_key=...)","Add a guard/early return upstream if client can legitimately be None in your flow"],"exampleFix":"# before\nstore = QdrantVectorStoreManager._check_create_collection(client=None, collection_name=\"c\", model=model)\n\n# after\nfrom qdrant_client import QdrantClient\nclient = QdrantClient(url=\"http://localhost:6333\")\nstore = QdrantVectorStoreManager._check_create_collection(client=client, collection_name=\"c\", model=model)","handlingStrategy":"validation","validationCode":"def make_qdrant_client(url, api_key=None):\n    from qdrant_client import QdrantClient\n    client = QdrantClient(url=url, api_key=api_key)\n    assert client is not None\n    return client\n\n# then always pass make_qdrant_client(...) instead of a possibly-None variable","typeGuard":null,"tryCatchPattern":"try:\n    store = QdrantVectorStoreManager._check_create_collection(client=client, collection_name=c, model=m)\nexcept ValueError as e:\n    if \"not initialized\" in str(e):\n        client = QdrantClient(url=URL, api_key=KEY)\n        store = QdrantVectorStoreManager._check_create_collection(client=client, collection_name=c, model=m)\n    else:\n        raise","preventionTips":["Never call _check_create_collection directly; use the public create_or_update_vector_store","Type-annotate helpers as client: QdrantClient (not Optional) so static checkers catch None","Construct the client immediately before use and assert it is not None"],"tags":["qdrant","vector-db","null-argument","internal-api"],"backgroundTag":"null-argument-validation","analyzedSha":"fb951af7744dab086e34962e9bc6fe878e145f83","analyzedAt":"2026-08-28T11:56:54.780Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}