{"record":{"id":"09494d35d691881b","repo":"stanford-oval/storm","slug":"please-provide-an-api-key-09494d","errorCode":null,"errorMessage":"Please provide an api key.","messagePattern":"Please provide an api key\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"knowledge_storm/utils.py","lineNumber":116,"sourceCode":"                collection_name=collection_name,\n                embeddings=model,\n            )\n\n    @staticmethod\n    def _init_online_vector_db(\n        url: str, api_key: str, collection_name: str, model: \"HuggingFaceEmbeddings\"\n    ):\n        from qdrant_client import QdrantClient\n\n        \"\"\"Initialize the Qdrant client that is connected to an online vector store with the given URL and API key.\n\n        Args:\n            url (str): URL of the Qdrant server.\n            api_key (str): API key for the Qdrant server.\n        \"\"\"\n        if api_key is None:\n            if not os.getenv(\"QDRANT_API_KEY\"):\n                raise ValueError(\"Please provide an api key.\")\n            api_key = os.getenv(\"QDRANT_API_KEY\")\n        if url is None:\n            raise ValueError(\"Please provide a url for the Qdrant server.\")\n\n        try:\n            client = QdrantClient(url=url, api_key=api_key)\n            return QdrantVectorStoreManager._check_create_collection(\n                client=client, collection_name=collection_name, model=model\n            )\n        except Exception as e:\n            raise ValueError(f\"Error occurs when connecting to the server: {e}\")\n\n    @staticmethod\n    def _init_offline_vector_db(\n        vector_store_path: str, collection_name: str, model: \"HuggingFaceEmbeddings\"\n    ):\n        from qdrant_client import QdrantClient\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/stanford-oval/storm/blob/fb951af7744dab086e34962e9bc6fe878e145f83/knowledge_storm/utils.py#L98-L134","documentation":"Raised by QdrantVectorStoreManager._init_online_vector_db when no API key is available for the (remote/cloud) Qdrant server: the api_key argument is None and the QDRANT_API_KEY environment variable is unset. Remote Qdrant endpoints (especially Qdrant Cloud) require an API key, so the manager refuses to proceed without one.","triggerScenarios":"Calling create_or_update_vector_store(..., online_mode=True) or _init_online_vector_db(url=...) with api_key=None while QDRANT_API_KEY is not set. A locally reachable, keyless server still triggers it because the check is unconditional for online mode.","commonSituations":"Migrating from a local Qdrant (no auth) to Qdrant Cloud and forgetting the key; QDRANT_API_KEY defined in .env but never loaded; CI environment missing the secret; passing an empty-string key, which is falsy and fails the check.","solutions":["export QDRANT_API_KEY=\"<your-qdrant-api-key>\"","Or pass the argument: create_or_update_vector_store(..., online_mode=True, api_key=KEY, url=URL)","Load your .env before calling (python-dotenv load_dotenv()) if the key lives in a file"],"exampleFix":"# before\nstore = QdrantVectorStoreManager.create_or_update_vector_store(url=\"https://xyz.cloud.qdrant.io:6333\", online_mode=True, model=model, collection_name=\"c\")\n\n# after\nstore = QdrantVectorStoreManager.create_or_update_vector_store(url=\"https://xyz.cloud.qdrant.io:6333\", online_mode=True, model=model, collection_name=\"c\", api_key=\"<key>\")\n# or: export QDRANT_API_KEY=<key>","handlingStrategy":"validation","validationCode":"import os\n\ndef has_qdrant_key(explicit=None):\n    return bool(explicit or os.getenv(\"QDRANT_API_KEY\"))\n\nassert has_qdrant_key(), \"Set QDRANT_API_KEY or pass api_key for online mode\"","typeGuard":null,"tryCatchPattern":"try:\n    store = QdrantVectorStoreManager.create_or_update_vector_store(url=URL, online_mode=True, model=m, collection_name=c)\nexcept ValueError as e:\n    if \"api key\" in str(e):\n        raise SystemExit(\"QDRANT_API_KEY missing; add it to your environment\")\n    raise","preventionTips":["Keep QDRANT_API_KEY next to QDRANT_URL in your secrets store so they're set together","Use offline mode (vector_store_path) for local keyless experiments","load_dotenv() at startup when config lives in .env"],"tags":["qdrant","env-var","api-key","vector-db"],"backgroundTag":"missing-env-var","analyzedSha":"fb951af7744dab086e34962e9bc6fe878e145f83","analyzedAt":"2026-08-28T11:56:54.780Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}