infiniflow/ragflow · error · ValueError

Invalid results format from BGPT

Error message

Invalid results format from BGPT

What it means

Error "Invalid results format from BGPT" thrown in infiniflow/ragflow.

Source

Thrown at agent/tools/bgpt.py:107

        if self._param.days_back:
            payload["days_back"] = self._param.days_back

        last_e = ""
        for _ in range(self._param.max_retries + 1):
            if self.check_if_canceled("BGPT processing"):
                return

            try:
                response = requests.post(BGPT_SEARCH_URL, json=payload, timeout=25)
                response.raise_for_status()
                data = response.json()

                if not data or not isinstance(data, dict):
                    raise ValueError("Invalid response from BGPT")

                results = data.get("results", [])
                if not isinstance(results, list):
                    raise ValueError("Invalid results format from BGPT")

                if self.check_if_canceled("BGPT processing"):
                    return

                self._retrieve_chunks(
                    results,
                    get_title=lambda paper: paper.get("title") or "Untitled",
                    get_url=lambda paper: paper.get("url") or paper.get("doi") or "",
                    get_content=lambda paper: self._format_bgpt_paper(paper),
                )
                self.set_output("json", results)
                return self.output("formalized_content")

            except requests.HTTPError as e:
                # Non-retryable 4xx (e.g. 400/401/403/404) should fail fast
                # rather than wasting retries on bad requests or auth failures.
                status = e.response.status_code if e.response is not None else None
                if status is not None and 400 <= status < 500 and status != 429:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Inspect the raw BGPT response; it must contain the expected results array.
  2. Handle empty or missing results explicitly before iterating.

Example fix

data = resp.json()
results = data.get('results')
if not isinstance(results, list):
    raise Exception('Invalid results format from BGPT')

When it happens

Trigger: Thrown at agent/tools/bgpt.py:107 when the library encounters an invalid state.

Common situations: BGPT API contract changes or partial responses lack the expected results field; checking the structure with isinstance before use prevents this error.


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/a696c8e4b0c346a3. Report an issue: GitHub.