{"record":{"id":"77907a0376a4b5ec","repo":"stanford-oval/storm","slug":"error-occurs-when-connecting-to-the-server-e","errorCode":null,"errorMessage":"Error occurs when connecting to the server: {e}","messagePattern":"Error occurs when connecting to the server: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"knowledge_storm/rm.py","lineNumber":271,"sourceCode":"        \"\"\"\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.\n        \"\"\"\n        if vector_store_path is None:\n            raise ValueError(\"Please provide a folder path.\")\n\n        try:\n            self.client = QdrantClient(path=vector_store_path)\n            self._check_collection()\n        except Exception as e:\n            raise ValueError(f\"Error occurs when loading the vector store: {e}\")","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/stanford-oval/storm/blob/fb951af7744dab086e34962e9bc6fe878e145f83/knowledge_storm/rm.py#L253-L289","documentation":"init_online_vector_db wraps QdrantClient construction and _check_collection in a try/except that re-raises any failure as ValueError('Error occurs when connecting to the server: {e}'). The original exception text is appended, so the root cause (DNS, TLS, 401, timeout, missing collection) appears inside the message.","triggerScenarios":"Unreachable/wrong url (DNS failure, wrong port); invalid API key (401/403); network egress blocked; or _check_collection raising because the collection does not exist — all get bundled into this single error.","commonSituations":"Typo'd cluster URL; expired or rotated Qdrant Cloud API key; firewall/proxy blocking port 6333; pointing at a local Qdrant that is not running; collection-name mismatch surfacing through this wrapper.","solutions":["Read the appended inner message to identify the true cause (auth vs connectivity vs missing collection)","Verify connectivity: curl https://<url>/collections with the api-key header; check the key in the Qdrant Cloud dashboard","Confirm the collection exists on that server (see the 'does not exist' error) and the URL includes the right port","If behind a proxy, set HTTPS_PROXY or use a QdrantClient configured for it"],"exampleFix":"// before\nrm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333', api_key=key)  # ValueError: Error occurs when connecting to the server: ...\n// after\nimport requests\nassert requests.get('https://xyz.cloud.qdrant.io:6333/collections', headers={'api-key': key}).status_code == 200\nrm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333', api_key=key)","handlingStrategy":"retry","validationCode":"import requests\nresp = requests.get(f'{QDRANT_URL}/collections', headers={'api-key': QDRANT_API_KEY}, timeout=10)\nif resp.status_code != 200:\n    raise SystemExit(f'Qdrant unreachable or unauthorized: HTTP {resp.status_code}')\nrm.init_online_vector_db(url=QDRANT_URL, api_key=QDRANT_API_KEY)","typeGuard":"def qdrant_reachable(url: str, api_key: str) -> bool:\n    import requests\n    try:\n        return requests.get(f'{url}/collections', headers={'api-key': api_key}, timeout=10).status_code == 200\n    except requests.RequestException:\n        return False","tryCatchPattern":"from tenacity import retry, wait_exponential, stop_after_attempt\n@retry(wait=wait_exponential(multiplier=2), stop=stop_after_attempt(3), reraise=True)\ndef connect(rm, url, key):\n    try:\n        rm.init_online_vector_db(url=url, api_key=key)\n    except ValueError as e:\n        msg = str(e)\n        if '401' in msg or '403' in msg:\n            raise SystemExit('Bad Qdrant credentials')  # don't retry auth errors\n        raise  # retry transient network/5xx","preventionTips":["Health-check the endpoint with a cheap GET before starting a long pipeline","Separate auth failures (fix key) from connectivity failures (fix network) using the embedded status text"],"tags":["python","qdrant","network","connection-failed","error-wrapping"],"backgroundTag":"connection-refused","analyzedSha":"fb951af7744dab086e34962e9bc6fe878e145f83","analyzedAt":"2026-08-28T11:56:54.780Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}