{"record":{"id":"032eca8a1681c9cf","repo":"stanford-oval/storm","slug":"error-unable-to-retrieve-results-status-code-r","errorCode":null,"errorMessage":"Error: Unable to retrieve results. Status code: {response.status_code}","messagePattern":"Error: Unable to retrieve results\\. Status code: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"knowledge_storm/rm.py","lineNumber":383,"sourceCode":"            results = []\n            for response_data in response_data_list:\n                result = {\n                    \"title\": response_data[\"document_title\"],\n                    \"url\": response_data[\"url\"],\n                    \"snippets\": [response_data[\"content\"]],\n                    \"description\": response_data.get(\"description\", \"N/A\"),\n                    \"meta\": {\n                        key: value\n                        for key, value in response_data.items()\n                        if key not in [\"document_title\", \"url\", \"content\"]\n                    },\n                }\n\n                results.append(result)\n\n            return results\n        else:\n            raise Exception(\n                f\"Error: Unable to retrieve results. Status code: {response.status_code}\"\n            )\n\n    def forward(\n        self, query_or_queries: Union[str, List[str]], exclude_urls: List[str] = []\n    ):\n        collected_results = []\n        queries = (\n            [query_or_queries]\n            if isinstance(query_or_queries, str)\n            else query_or_queries\n        )\n\n        for query in queries:\n            try:\n                results = self._retrieve(query)\n                collected_results.extend(results)\n            except Exception as e:","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/stanford-oval/storm/blob/fb951af7744dab086e34962e9bc6fe878e145f83/knowledge_storm/rm.py#L365-L401","documentation":"VectorRM._retrieve queries the You.com web-search API and, when the HTTP response status is not 200, raises a generic Exception with the status code. This surfaces through forward() when running STORM with source='you'. The status code distinguishes causes: 401/403 bad API key, 429 rate limit, 4xx bad params, 5xx upstream outage.","triggerScenarios":"Calling rm.forward(...) / a STORM pipeline run with engine='you' when the You.com API returns non-200: invalid or unset YDC_API_KEY, exhausted quota/rate limit, or transient 5xx from the service.","commonSituations":"Expired You.com API key or key never exported; free-tier rate limits during a long multi-query STORM run (many queries per article); transient upstream errors treated as fatal because any non-200 raises.","solutions":["Check the status code in the message: 401/403 -> fix YDC_API_KEY; 429 -> add backoff/retries or reduce k/query_params['num']; 5xx -> retry after a delay","Verify the key: echo $YDC_API_KEY and test a single curl request to the You.com API","Catch the exception per-query in your pipeline so one failed search doesn't kill the whole run","If limits persist, switch VectorRM to another source (serper, bing, etc.)"],"exampleFix":"// before\nresults = rm.forward([query])  # Exception: Error: Unable to retrieve results. Status code: 429\n// after\nfrom tenacity import retry, wait_exponential, stop_after_attempt\n@retry(wait=wait_exponential(multiplier=2), stop=stop_after_attempt(4))\ndef safe_forward(rm, q):\n    try:\n        return rm.forward(q)\n    except Exception as e:\n        if '429' in str(e) or '5' in str(e).split()[-1]:\n            raise\n        return []\nresults = safe_forward(rm, [query])","handlingStrategy":"retry","validationCode":"import os\nif not os.getenv('YDC_API_KEY'):\n    raise SystemExit('Set YDC_API_KEY for the you.com retrieval source')","typeGuard":null,"tryCatchPattern":"import time\ndef search_with_retry(rm, query, attempts=4):\n    for i in range(attempts):\n        try:\n            return rm.forward(query)\n        except Exception as e:\n            code = str(e).rsplit(' ', 1)[-1]\n            if code in ('401', '403'):\n                raise SystemExit('Invalid YDC_API_KEY')\n            if i == attempts - 1:\n                return []  # degrade gracefully per-query\n            time.sleep(2 ** (i + 1))\n    return []","preventionTips":["Validate YDC_API_KEY before starting a long STORM run","Wrap per-query retrieval so one failed search returns [] instead of aborting the article generation","Use exponential backoff for 429/5xx and reduce k or query_params['num'] if rate limits persist"],"tags":["python","web-search","http-status","rate-limit","api"],"backgroundTag":"http-request-failed","analyzedSha":"fb951af7744dab086e34962e9bc6fe878e145f83","analyzedAt":"2026-08-28T11:56:54.780Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}