{"record":{"id":"38c7ba1b89c888e5","repo":"stanford-oval/storm","slug":"please-provide-an-api-key","errorCode":null,"errorMessage":"Please provide an api key.","messagePattern":"Please provide an api key\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"knowledge_storm/rm.py","lineNumber":262,"sourceCode":"            )\n        else:\n            raise ValueError(\n                f\"Collection {self.collection_name} does not exist. Please create the collection first.\"\n            )\n\n    def init_online_vector_db(self, url: str, api_key: str):\n        from qdrant_client import QdrantClient\n\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            self.client = QdrantClient(url=url, api_key=api_key)\n            self._check_collection()\n        except Exception as e:\n            raise ValueError(f\"Error occurs when connecting to the server: {e}\")\n\n    def init_offline_vector_db(self, vector_store_path: str):\n        from qdrant_client import QdrantClient\n\n        \"\"\"\n        Initialize the Qdrant client that is connected to an offline vector store with the given vector store folder path.\n\n        Args:\n            vector_store_path (str): Path to the vector store.","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/stanford-oval/storm/blob/fb951af7744dab086e34962e9bc6fe878e145f83/knowledge_storm/rm.py#L244-L280","documentation":"For source='online', VectorRM.init_online_vector_db requires an api_key either as an argument or via the QDRANT_API_KEY environment variable. If neither is present it raises ValueError before constructing the QdrantClient, since managed/Qdrant Cloud endpoints authenticate with API keys.","triggerScenarios":"Calling rm.init_online_vector_db(url='https://xyz.eu-central.aws.cloud.qdrant.io:6333') without api_key while QDRANT_API_KEY is unset; calling with api_key=None explicitly; CI shells where .env was never loaded.","commonSituations":"Forgetting to export QDRANT_API_KEY in the shell/CI; assuming the key is read from a .env file automatically without python-dotenv; copying examples that only pass url.","solutions":["Pass api_key directly: rm.init_online_vector_db(url=..., api_key='your-key')","Or export the environment variable: export QDRANT_API_KEY=your-key (and load it in code via load_dotenv() if using .env)","Copy the key from Qdrant Cloud dashboard -> API Keys for your cluster"],"exampleFix":"// before\nrm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333')\n// after\nrm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333', api_key=os.environ['QDRANT_API_KEY'])","handlingStrategy":"validation","validationCode":"import os\napi_key = os.getenv('QDRANT_API_KEY')\nif not api_key:\n    raise SystemExit('Set QDRANT_API_KEY or pass api_key= to init_online_vector_db')\nrm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333', api_key=api_key)","typeGuard":"def has_qdrant_credentials(api_key: str | None) -> bool:\n    import os\n    return bool(api_key or os.getenv('QDRANT_API_KEY'))","tryCatchPattern":"try:\n    rm.init_online_vector_db(url=URL, api_key=None)\nexcept ValueError as e:\n    if 'api key' in str(e):\n        raise SystemExit('Missing QDRANT_API_KEY — add it to your environment')\n    raise","preventionTips":["Load credentials via load_dotenv() at process start","Add QDRANT_API_KEY to CI secrets and fail fast at boot if absent"],"tags":["python","qdrant","authentication","missing-env-var"],"backgroundTag":"missing-api-key","analyzedSha":"fb951af7744dab086e34962e9bc6fe878e145f83","analyzedAt":"2026-08-28T11:56:54.780Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}