{"record":{"id":"133097e6c82456c5","repo":"infiniflow/ragflow","slug":"querit-api-response-field-results-must-be-an-objec","errorCode":null,"errorMessage":"Querit API response field results must be an object.","messagePattern":"Querit API response field results must be an object\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"agent/tools/querit.py","lineNumber":174,"sourceCode":"                \"chunks_per_doc\",\n                \"site_include\",\n                \"site_exclude\",\n                \"time_range\",\n                \"country_include\",\n                \"language_include\",\n            )\n        }\n\n        try:\n            _validate_search_inputs(**values)\n            payload = _build_payload(query, **values)\n            response_data = self._search(payload, api_key)\n            if not isinstance(response_data, dict):\n                raise TypeError(\"Querit API response must be a JSON object.\")\n\n            result_container = response_data.get(\"results\", {})\n            if not isinstance(result_container, dict):\n                raise TypeError(\"Querit API response field results must be an object.\")\n            results = result_container.get(\"result\", [])\n            if not isinstance(results, list):\n                raise TypeError(\"Querit API response field results.result must be an array.\")\n\n            reference_results = [item for item in results if isinstance(item, dict)]\n            if reference_results:\n                self._retrieve_chunks(\n                    reference_results,\n                    get_title=lambda item: _querit_text(item.get(\"title\")),\n                    get_url=lambda item: _querit_text(item.get(\"url\")),\n                    get_content=lambda item: _querit_text(item.get(\"snippet\")),\n                    get_score=lambda _item: 1,\n                )\n            else:\n                self.set_output(\"formalized_content\", \"\")\n            self.set_output(\"json\", response_data)\n            return self.output(\"formalized_content\")\n        except _QueritCanceled:","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/querit.py#L156-L192","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"def results_field_ok(data: dict) -> bool:\n    return isinstance(data.get(\"results\", {}), dict)","typeGuard":"def has_querit_results_object(v: Any) -> bool:\n    return isinstance(v, dict) and isinstance(v.get(\"results\"), dict)","tryCatchPattern":"try:\n    querit_search._invoke(query=q)\nexcept TypeError as e:\n    if \"results must be an object\" in str(e):\n        alert_api_contract_drift(e)\n    raise","preventionTips":["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."],"tags":["api","json","response-validation","querit"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}