{"record":{"id":"ab5049af1289beda","repo":"iflytek/astron-agent","slug":"max-wait-time-must-be-greater-than-0","errorCode":null,"errorMessage":"max_wait_time must be greater than 0","messagePattern":"max_wait_time must be greater than 0","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/knowledge/infra/ragflow/ragflow_client.py","lineNumber":957,"sourceCode":"        \"progress_msg\": progress_msg.replace(\"\\n\", \" | \")[:500],\n    }\n\n\ndef _format_parsing_snapshot(snapshot: Dict[str, Any]) -> str:\n    \"\"\"Format a compact status description for logs and propagated errors.\"\"\"\n    return (\n        f\"status={snapshot['status']}, progress={snapshot['progress']}, \"\n        f\"chunks={snapshot['chunk_count']}, tokens={snapshot['token_count']}, \"\n        f\"message={snapshot['progress_msg'] or '-'}\"\n    )\n\n\ndef _validate_parsing_wait_parameters(\n    max_wait_time: int, poll_interval: float, max_status_errors: int\n) -> None:\n    \"\"\"Reject polling configurations that cannot make forward progress.\"\"\"\n    if max_wait_time <= 0:\n        raise ValueError(\"max_wait_time must be greater than 0\")\n    if poll_interval <= 0:\n        raise ValueError(\"poll_interval must be greater than 0\")\n    if max_status_errors <= 0:\n        raise ValueError(\"max_status_errors must be greater than 0\")\n\n\nasync def _query_document_parsing_status(\n    dataset_id: str, doc_id: str\n) -> tuple[Optional[Dict[str, Any]], Optional[Exception]]:\n    \"\"\"Return a document snapshot or the recoverable query error.\"\"\"\n    try:\n        return await get_document_info(dataset_id, doc_id), None\n    except Exception as error:\n        return None, error\n\n\ndef _handle_parsing_status_error(\n    dataset_id: str,","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/infra/ragflow/ragflow_client.py#L939-L975","documentation":"_validate_parsing_wait_parameters rejects wait_for_parsing configurations where max_wait_time <= 0, since such a poller can never observe a completed parse. It is an upfront argument validation to prevent loops that make no forward progress.","triggerScenarios":"Calling wait_for_parsing with max_wait_time=0 (interpreted as 'no wait') or a negative value from a mis-parsed config, bad unit conversion (e.g. seconds vs milliseconds producing a tiny/negative number), or a None coerced through arithmetic.","commonSituations":"Config file specifying max_wait_time: 0 to mean 'unlimited'; environment variable parsing dropping a sign or unit; template defaults not substituted.","solutions":["Pass a positive max_wait_time (e.g. 300 seconds) to wait_for_parsing.","Fix the config/env source producing the non-positive value; check unit conversion.","If 'unlimited' was intended, use a large finite value instead of 0 — this API requires a positive bound.","Add a validation step on the config object at startup so the bad value fails early."],"exampleFix":"# before\nawait wait_for_parsing(ds, doc, max_wait_time=0)  # ValueError\n# after\nawait wait_for_parsing(ds, doc, max_wait_time=300, poll_interval=2.0)","handlingStrategy":"validation","validationCode":"assert max_wait_time > 0, \"max_wait_time must be a positive number of seconds\"","typeGuard":"def valid_wait(v) -> bool:\n    return isinstance(v, (int, float)) and v > 0","tryCatchPattern":"try:\n    await wait_for_parsing(ds, doc, max_wait_time=max_wait_time)\nexcept ValueError as e:\n    logger.error(f\"Invalid polling configuration: {e}\")\n    raise","preventionTips":["Validate polling config at startup, before any parse is started","Document that max_wait_time is seconds and must be positive","Use explicit large finite values for 'long waits'; 0 does not mean unlimited"],"tags":["ragflow","argument-validation","polling"],"backgroundTag":"invalid-argument-value","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}