stanford-oval/storm · error · ValueError

Error occurs when connecting to the server: {e}

Error message

Error occurs when connecting to the server: {e}

What it means

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.

Source

Thrown at knowledge_storm/rm.py:271

        """
        Initialize the Qdrant client that is connected to an online vector store with the given URL and API key.

        Args:
            url (str): URL of the Qdrant server.
            api_key (str): API key for the Qdrant server.
        """
        if api_key is None:
            if not os.getenv("QDRANT_API_KEY"):
                raise ValueError("Please provide an api key.")
            api_key = os.getenv("QDRANT_API_KEY")
        if url is None:
            raise ValueError("Please provide a url for the Qdrant server.")

        try:
            self.client = QdrantClient(url=url, api_key=api_key)
            self._check_collection()
        except Exception as e:
            raise ValueError(f"Error occurs when connecting to the server: {e}")

    def init_offline_vector_db(self, vector_store_path: str):
        from qdrant_client import QdrantClient

        """
        Initialize the Qdrant client that is connected to an offline vector store with the given vector store folder path.

        Args:
            vector_store_path (str): Path to the vector store.
        """
        if vector_store_path is None:
            raise ValueError("Please provide a folder path.")

        try:
            self.client = QdrantClient(path=vector_store_path)
            self._check_collection()
        except Exception as e:
            raise ValueError(f"Error occurs when loading the vector store: {e}")

View on GitHub (pinned to fb951af774)

Solutions

  1. Read the appended inner message to identify the true cause (auth vs connectivity vs missing collection)
  2. Verify connectivity: curl https://<url>/collections with the api-key header; check the key in the Qdrant Cloud dashboard
  3. Confirm the collection exists on that server (see the 'does not exist' error) and the URL includes the right port
  4. If behind a proxy, set HTTPS_PROXY or use a QdrantClient configured for it

Example fix

// before
rm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333', api_key=key)  # ValueError: Error occurs when connecting to the server: ...
// after
import requests
assert requests.get('https://xyz.cloud.qdrant.io:6333/collections', headers={'api-key': key}).status_code == 200
rm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333', api_key=key)
Defensive patterns

Strategy: retry

Validate before calling

import requests
resp = requests.get(f'{QDRANT_URL}/collections', headers={'api-key': QDRANT_API_KEY}, timeout=10)
if resp.status_code != 200:
    raise SystemExit(f'Qdrant unreachable or unauthorized: HTTP {resp.status_code}')
rm.init_online_vector_db(url=QDRANT_URL, api_key=QDRANT_API_KEY)

Type guard

def qdrant_reachable(url: str, api_key: str) -> bool:
    import requests
    try:
        return requests.get(f'{url}/collections', headers={'api-key': api_key}, timeout=10).status_code == 200
    except requests.RequestException:
        return False

Try / catch

from tenacity import retry, wait_exponential, stop_after_attempt
@retry(wait=wait_exponential(multiplier=2), stop=stop_after_attempt(3), reraise=True)
def connect(rm, url, key):
    try:
        rm.init_online_vector_db(url=url, api_key=key)
    except ValueError as e:
        msg = str(e)
        if '401' in msg or '403' in msg:
            raise SystemExit('Bad Qdrant credentials')  # don't retry auth errors
        raise  # retry transient network/5xx

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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