{"record":{"id":"864e12b6c289506e","repo":"infiniflow/ragflow","slug":"invalid-response-from-bgpt","errorCode":null,"errorMessage":"Invalid response from BGPT","messagePattern":"Invalid response from BGPT","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/tools/bgpt.py","lineNumber":103,"sourceCode":"\n        payload = {\"query\": query.strip(), \"num_results\": self._param.top_n}\n        if self._param.api_key:\n            payload[\"api_key\"] = self._param.api_key\n        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:","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/bgpt.py#L85-L121","documentation":"Error \"Invalid response from BGPT\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at agent/tools/bgpt.py:103 when the library encounters an invalid state.","commonSituations":"BGPT service returns an error status, an empty body, or non-JSON content; validating the HTTP status and payload shape before parsing prevents this error.","solutions":["Check that the BGPT endpoint returned a well-formed response body.","Verify BGPT_API_KEY and endpoint configuration, then retry."],"exampleFix":"resp = requests.post(url, json=payload, timeout=30)\nif not resp.ok:\n    raise Exception(f'Invalid response from BGPT: {resp.status_code}')\nreturn resp.json()","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"}