{"record":{"id":"f88f4f8bf2967a21","repo":"infiniflow/ragflow","slug":"querit-api-response-field-results-must-be-an-array","errorCode":null,"errorMessage":"Querit API response field results must be an array.","messagePattern":"Querit API response field results must be an array\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"agent/tools/querit.py","lineNumber":391,"sourceCode":"    if not isinstance(urls, list) or not 1 <= len(urls) <= 10 or any(not isinstance(url, str) or not url.strip() for url in urls):\n        raise ValueError(\"Querit urls must contain between 1 and 10 non-empty strings.\")\n    for url in urls:\n        parsed = urlparse(url)\n        if parsed.scheme not in {\"http\", \"https\"} or not parsed.netloc:\n            raise ValueError(\"Querit urls must be absolute HTTP or HTTPS URLs.\")\n    if format not in QUERIT_CONTENT_FORMATS:\n        raise ValueError(\"Querit format must be text, markdown, or html.\")\n    if type(crawl_timeout) is not int or not 1 <= crawl_timeout <= 60:\n        raise ValueError(\"Querit crawl_timeout must be an integer from 1 to 60.\")\n    if type(extras_meta) is not bool:\n        raise ValueError(\"Querit extras_meta must be a boolean.\")\n\n\ndef _validate_contents_response(response_data: Any) -> None:\n    if not isinstance(response_data, dict):\n        raise TypeError(\"Querit API response must be a JSON object.\")\n    if \"results\" in response_data and not isinstance(response_data[\"results\"], list):\n        raise TypeError(\"Querit API response field results must be an array.\")\n    if \"statuses\" in response_data and not isinstance(response_data[\"statuses\"], list):\n        raise TypeError(\"Querit API response field statuses must be an array.\")\n\n\ndef _validate_search_inputs(\n    count: Any,\n    chunks_per_doc: Any,\n    time_range: Any,\n    site_include: Any,\n    site_exclude: Any,\n    country_include: Any,\n    language_include: Any,\n) -> None:\n    if type(count) is not int or count < 1:\n        raise ValueError(\"Querit count must be an integer greater than or equal to 1.\")\n    if chunks_per_doc is not None and (type(chunks_per_doc) is not int or not 1 <= chunks_per_doc <= 3):\n        raise ValueError(\"Querit chunks_per_doc must be an integer from 1 to 3.\")\n    if type(time_range) is not str:","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/querit.py#L373-L409","documentation":"TypeError from _validate_contents_response(): when the response object contains a 'results' key, its value must be an array (list). The key is optional, but if present it cannot be a dict, string, or null.","triggerScenarios":"A contents response like {\"results\": {\"docs\": [...]}} or {\"results\": null} — schema drift or an error branch reusing the field with a different type.","commonSituations":"APIs collapsing the array to null for empty crawls; newer API versions nesting results under an object; stale mocks with dict-shaped results.","solutions":["Verify with curl that 'results' (when present) is a JSON array.","Treat null as absent in an adapter layer if the API documents that, then re-validate.","Pin the API version matching the array contract.","Fix test fixtures."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"def contents_results_ok(data: dict) -> bool:\n    return \"results\" not in data or isinstance(data[\"results\"], list)","typeGuard":"from typing import Any\ndef has_list_results(v: Any) -> bool:\n    return not isinstance(v, dict) or \"results\" not in v or isinstance(v[\"results\"], list)","tryCatchPattern":"try:\n    querit_contents._invoke(urls=urls)\nexcept TypeError as e:\n    if \"results must be an array\" in str(e):\n        alert_api_contract_drift(e)\n    raise","preventionTips":["Pin the API version; notify owners when arrays become objects/null.","Centralize response-shape checks in one adapter."],"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"}