{"record":{"id":"a696c8e4b0c346a3","repo":"infiniflow/ragflow","slug":"invalid-results-format-from-bgpt","errorCode":null,"errorMessage":"Invalid results format from BGPT","messagePattern":"Invalid results format from BGPT","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/tools/bgpt.py","lineNumber":107,"sourceCode":"        if self._param.days_back:\n            payload[\"days_back\"] = self._param.days_back\n\n        last_e = \"\"\n        for _ in range(self._param.max_retries + 1):\n            if self.check_if_canceled(\"BGPT processing\"):\n                return\n\n            try:\n                response = requests.post(BGPT_SEARCH_URL, json=payload, timeout=25)\n                response.raise_for_status()\n                data = response.json()\n\n                if not data or not isinstance(data, dict):\n                    raise ValueError(\"Invalid response from BGPT\")\n\n                results = data.get(\"results\", [])\n                if not isinstance(results, list):\n                    raise ValueError(\"Invalid results format from BGPT\")\n\n                if self.check_if_canceled(\"BGPT processing\"):\n                    return\n\n                self._retrieve_chunks(\n                    results,\n                    get_title=lambda paper: paper.get(\"title\") or \"Untitled\",\n                    get_url=lambda paper: paper.get(\"url\") or paper.get(\"doi\") or \"\",\n                    get_content=lambda paper: self._format_bgpt_paper(paper),\n                )\n                self.set_output(\"json\", results)\n                return self.output(\"formalized_content\")\n\n            except requests.HTTPError as e:\n                # Non-retryable 4xx (e.g. 400/401/403/404) should fail fast\n                # rather than wasting retries on bad requests or auth failures.\n                status = e.response.status_code if e.response is not None else None\n                if status is not None and 400 <= status < 500 and status != 429:","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/bgpt.py#L89-L125","documentation":"Error \"Invalid results format from BGPT\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at agent/tools/bgpt.py:107 when the library encounters an invalid state.","commonSituations":"BGPT API contract changes or partial responses lack the expected results field; checking the structure with isinstance before use prevents this error.","solutions":["Inspect the raw BGPT response; it must contain the expected results array.","Handle empty or missing results explicitly before iterating."],"exampleFix":"data = resp.json()\nresults = data.get('results')\nif not isinstance(results, list):\n    raise Exception('Invalid results format from BGPT')","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}