stanford-oval/storm · error · RuntimeError

Error had occurred while running the search process. Error

Error message

Error had occurred while running the search process.
 Error is {response.reason}, had failed with status code {response.status_code}

What it means

Raised by SerperRM.serper_runner when a POST to Serper.dev's search API returns a response the client treats as failed. The check is actually broken: requests.request never returns None, so in practice the error path is reached only via falsy responses, and the f-string reads response.reason/status_code which would themselves fail on a falsy object. It signals the search backend call did not succeed.

Source

Thrown at knowledge_storm/rm.py:479

        else:
            self.serper_search_api_key = os.environ["SERPER_API_KEY"]

        self.base_url = "https://google.serper.dev"

    def serper_runner(self, query_params):
        self.search_url = f"{self.base_url}/search"

        headers = {
            "X-API-KEY": self.serper_search_api_key,
            "Content-Type": "application/json",
        }

        response = requests.request(
            "POST", self.search_url, headers=headers, json=query_params
        )

        if response == None:
            raise RuntimeError(
                f"Error had occurred while running the search process.\n Error is {response.reason}, had failed with status code {response.status_code}"
            )

        return response.json()

    def get_usage_and_reset(self):
        usage = self.usage
        self.usage = 0
        return {"SerperRM": usage}

    def forward(self, query_or_queries: Union[str, List[str]], exclude_urls: List[str]):
        """
        Calls the API and searches for the query passed in.


        Args:
            query_or_queries (Union[str, List[str]]): The query or queries to search for.
            exclude_urls (List[str]): Dummy parameter to match the interface. Does not have any effect.

View on GitHub (pinned to fb951af774)

Solutions

  1. Verify SERPER_API_KEY is set and valid by curl-ing https://google.serper.dev/search directly
  2. Check network connectivity / proxy settings from the host
  3. Retry after rate-limit window or upgrade Serper plan
  4. Catch RuntimeError around forward() and fall back to another retrieval module (e.g. DuckDuckGoRM)

Example fix

# before
results = serper_rm(query, exclude_urls=[])

# after
try:
    results = serper_rm(query, exclude_urls=[])
except RuntimeError as e:
    logger.warning(f"Serper search failed: {e}; falling back")
    results = duckduckgo_rm(query, exclude_urls=[])
Defensive patterns

Strategy: fallback

Validate before calling

import requests, os
def serper_reachable(api_key: str) -> bool:
    try:
        r = requests.post(
            "https://google.serper.dev/search",
            headers={"X-API-KEY": api_key, "Content-Type": "application/json"},
            json={"q": "ping"}, timeout=10,
        )
        return r.status_code == 200
    except requests.RequestException:
        return False
assert serper_reachable(os.environ["SERPER_API_KEY"])

Try / catch

try:
    results = serper_rm(query, exclude_urls=[])
except (RuntimeError, requests.RequestException) as e:
    logger.warning(f"Serper failed: {e}; using fallback retriever")
    results = fallback_rm(query, exclude_urls=[])

Prevention

When it happens

Trigger: Calling serper_runner (via forward/retrieval) when the Serper API is unreachable, returns a non-200 response, or when search_api_key is invalid and the service rejects the request. Also triggered by network errors proxied through a falsy/failed response object.

Common situations: Invalid or expired SERPER_API_KEY, hitting Serper rate limits, network egress blocked from the host, or an outage at serper.dev.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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