infiniflow/ragflow · error · TypeError
Querit API response field results must be an object.
Error message
Querit API response field results must be an object.
What it means
TypeError raised by the Querit search tool when response_data is a dict but its 'results' field is not itself an object (dict). The code does response_data.get("results", {}) and requires an object; a list, string, or null in that field fails this check.
Source
Thrown at agent/tools/querit.py:174
"chunks_per_doc",
"site_include",
"site_exclude",
"time_range",
"country_include",
"language_include",
)
}
try:
_validate_search_inputs(**values)
payload = _build_payload(query, **values)
response_data = self._search(payload, api_key)
if not isinstance(response_data, dict):
raise TypeError("Querit API response must be a JSON object.")
result_container = response_data.get("results", {})
if not isinstance(result_container, dict):
raise TypeError("Querit API response field results must be an object.")
results = result_container.get("result", [])
if not isinstance(results, list):
raise TypeError("Querit API response field results.result must be an array.")
reference_results = [item for item in results if isinstance(item, dict)]
if reference_results:
self._retrieve_chunks(
reference_results,
get_title=lambda item: _querit_text(item.get("title")),
get_url=lambda item: _querit_text(item.get("url")),
get_content=lambda item: _querit_text(item.get("snippet")),
get_score=lambda _item: 1,
)
else:
self.set_output("formalized_content", "")
self.set_output("json", response_data)
return self.output("formalized_content")
except _QueritCanceled:View on GitHub (pinned to 554fb1133a)
Solutions
- curl the search endpoint and inspect typeof body.results — it must be an object containing a 'result' array.
- If the upstream schema changed to an array, pin/adapt the client to the version whose contract is {"results": {"result": []}}.
- Handle {"results": null} as 'no results' upstream if the API documents that, instead of letting the TypeError propagate.
- Update test fixtures that accidentally use a list for 'results'.
Defensive patterns
Strategy: type-guard
Validate before calling
def results_field_ok(data: dict) -> bool:
return isinstance(data.get("results", {}), dict) Type guard
def has_querit_results_object(v: Any) -> bool:
return isinstance(v, dict) and isinstance(v.get("results"), dict) Try / catch
try:
querit_search._invoke(query=q)
except TypeError as e:
if "results must be an object" in str(e):
alert_api_contract_drift(e)
raise Prevention
- Pin the Querit API version in the client configuration.
- Add jsonschema validation of upstream responses in integration tests.
- Log the raw payload on shape violations to speed up drift diagnosis.
When it happens
Trigger: A response like {"results": [ ... ]} (results as array), {"results": null}, or {"results": "ok"} from the Querit search endpoint — typically a schema change or a partial/error payload that reuses the field with a different type.
Common situations: Querit API version drift where 'results' became a top-level array for single-query responses; responses from an error branch like {"error": "...", "results": null}; contract-test fixtures typed loosely.
Related errors
- Querit API response must be a JSON object.
- Querit API response field results.result must be an array.
- Querit API response field results must be an array.
- Querit API response field statuses must be an array.
- 'str' object has no attribute 'get'
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/133097e6c82456c5.
Report an issue: GitHub.