{"record":{"id":"279aafdd1eb94809","repo":"stanford-oval/storm","slug":"error-had-occurred-while-running-the-search-proces","errorCode":null,"errorMessage":"Error had occurred while running the search process.\n Error is {response.reason}, had failed with status code {response.status_code}","messagePattern":"Error had occurred while running the search process\\.\n Error is (.+?), had failed with status code (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"knowledge_storm/rm.py","lineNumber":479,"sourceCode":"        else:\n            self.serper_search_api_key = os.environ[\"SERPER_API_KEY\"]\n\n        self.base_url = \"https://google.serper.dev\"\n\n    def serper_runner(self, query_params):\n        self.search_url = f\"{self.base_url}/search\"\n\n        headers = {\n            \"X-API-KEY\": self.serper_search_api_key,\n            \"Content-Type\": \"application/json\",\n        }\n\n        response = requests.request(\n            \"POST\", self.search_url, headers=headers, json=query_params\n        )\n\n        if response == None:\n            raise RuntimeError(\n                f\"Error had occurred while running the search process.\\n Error is {response.reason}, had failed with status code {response.status_code}\"\n            )\n\n        return response.json()\n\n    def get_usage_and_reset(self):\n        usage = self.usage\n        self.usage = 0\n        return {\"SerperRM\": usage}\n\n    def forward(self, query_or_queries: Union[str, List[str]], exclude_urls: List[str]):\n        \"\"\"\n        Calls the API and searches for the query passed in.\n\n\n        Args:\n            query_or_queries (Union[str, List[str]]): The query or queries to search for.\n            exclude_urls (List[str]): Dummy parameter to match the interface. Does not have any effect.","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/stanford-oval/storm/blob/fb951af7744dab086e34962e9bc6fe878e145f83/knowledge_storm/rm.py#L461-L497","documentation":"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.","triggerScenarios":"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.","commonSituations":"Invalid or expired SERPER_API_KEY, hitting Serper rate limits, network egress blocked from the host, or an outage at serper.dev.","solutions":["Verify SERPER_API_KEY is set and valid by curl-ing https://google.serper.dev/search directly","Check network connectivity / proxy settings from the host","Retry after rate-limit window or upgrade Serper plan","Catch RuntimeError around forward() and fall back to another retrieval module (e.g. DuckDuckGoRM)"],"exampleFix":"# before\nresults = serper_rm(query, exclude_urls=[])\n\n# after\ntry:\n    results = serper_rm(query, exclude_urls=[])\nexcept RuntimeError as e:\n    logger.warning(f\"Serper search failed: {e}; falling back\")\n    results = duckduckgo_rm(query, exclude_urls=[])","handlingStrategy":"fallback","validationCode":"import requests, os\ndef serper_reachable(api_key: str) -> bool:\n    try:\n        r = requests.post(\n            \"https://google.serper.dev/search\",\n            headers={\"X-API-KEY\": api_key, \"Content-Type\": \"application/json\"},\n            json={\"q\": \"ping\"}, timeout=10,\n        )\n        return r.status_code == 200\n    except requests.RequestException:\n        return False\nassert serper_reachable(os.environ[\"SERPER_API_KEY\"])","typeGuard":null,"tryCatchPattern":"try:\n    results = serper_rm(query, exclude_urls=[])\nexcept (RuntimeError, requests.RequestException) as e:\n    logger.warning(f\"Serper failed: {e}; using fallback retriever\")\n    results = fallback_rm(query, exclude_urls=[])","preventionTips":["Health-check the Serper endpoint and key at startup","Set requests timeouts so failures surface fast","Keep a secondary retriever configured for fallback","Monitor Serper status/quotas"],"tags":["network","search-api","serper","api-key","http"],"backgroundTag":"http-request-failed","analyzedSha":"fb951af7744dab086e34962e9bc6fe878e145f83","analyzedAt":"2026-08-28T11:56:54.780Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}