{"record":{"id":"3cfa54dd7c5eef90","repo":"infiniflow/ragflow","slug":"querit-count-must-be-an-integer-greater-than-or-eq","errorCode":null,"errorMessage":"Querit count must be an integer greater than or equal to 1.","messagePattern":"Querit count must be an integer greater than or equal to 1\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/tools/querit.py","lineNumber":406,"sourceCode":"    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:\n        raise ValueError(\"Querit time_range must be a string.\")\n    if time_range and not TIME_RANGE_PATTERN.fullmatch(time_range):\n        raise ValueError(\"Querit time_range must use dN, wN, mN, yN, or YYYY-MM-DDtoYYYY-MM-DD.\")\n    for name, value in (\n        (\"site_include\", site_include),\n        (\"site_exclude\", site_exclude),\n        (\"country_include\", country_include),\n        (\"language_include\", language_include),\n    ):\n        if not isinstance(value, list) or any(not isinstance(item, str) for item in value):\n            raise ValueError(f\"Querit {name} must be an array of strings.\")\n\n\ndef _safe_error_message(error: Exception, api_key: str) -> str:\n    message = str(error) or error.__class__.__name__","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/querit.py#L388-L424","documentation":"ValueError from _validate_search_inputs(): the 'count' parameter of Querit search must be a strict int (type(count) is int, excluding bool) and >= 1. Floats, numeric strings, None, booleans, and zero/negative values raise.","triggerScenarios":"count=10.0 (float from JSON config), count=\"10\" (string from a form), count=None when the field is omitted, count=0 from an upstream node defaulting to zero, count=True passing isinstance but failing type().","commonSituations":"Canvas input fields delivering strings; agent parameter interpolation; Python callers passing math.ceil() results (float in some paths) or numpy ints.","solutions":["Pass count as a plain int >= 1, e.g. count=10.","Coerce in your caller: count = int(count) after validating it is numeric and positive.","Check for numpy scalars — wrap with int(np.int64_value) before invoking.","Default missing values to a sane positive constant rather than None."],"exampleFix":"# before\ncount = \"10\"  # ValueError\n\n# after\ncount = int(count) if str(count).isdigit() else 10","handlingStrategy":"validation","validationCode":"def safe_querit_count(v) -> int:\n    return max(1, int(v)) if str(v).lstrip('-').replace('.','',1).isdigit() else 10","typeGuard":"def is_valid_querit_count(v) -> bool:\n    return type(v) is int and v >= 1","tryCatchPattern":"try:\n    querit_search._invoke(query=q, count=n)\nexcept ValueError as e:\n    if \"count\" in str(e):\n        n = 10; querit_search._invoke(query=q, count=n)\n    raise","preventionTips":["Convert numeric strings and numpy ints with int() at the boundary.","Use UI numeric inputs with min=1.","Default missing count to 10 instead of None."],"tags":["validation","input","querit","integer"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}