{"record":{"id":"6ce30395b19e3e96","repo":"iflytek/astron-agent","slug":"parameterinvalid","errorCode":"ParameterInvalid","errorMessage":"File type retrieval failed: {file_url}","messagePattern":"File type retrieval failed: (.+?)","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/knowledge/infra/aiui/aiui.py","lineNumber":136,"sourceCode":"        Parse results\n\n    Raises:\n        CustomException: When file type retrieval fails or resource type does not exist\n    \"\"\"\n    post_body = {\"file\": file_url, \"fileType\": \"pdf\", \"useLayout\": False}\n\n    if resource_type == 0:\n        image_extensions = {\"jpg\", \"jpeg\", \"png\", \"bmp\"}\n        file_extension = get_file_extension_from_url(file_url)\n\n        if check_not_empty(file_extension):\n            post_body[\"fileType\"] = file_extension\n            post_body[\"useLayout\"] = file_extension.upper() == \"PDF\"\n\n            if file_extension.lower() in image_extensions:\n                post_body[\"fileType\"] = \"image\"\n        else:\n            raise CustomException(\n                e=CodeEnum.ParameterInvalid,\n                msg=f\"File type retrieval failed: {file_url}\",\n            )\n    elif resource_type == 1:\n        post_body[\"fileType\"] = \"url\"\n    else:\n        raise CustomException(\n            e=CodeEnum.ParameterInvalid,\n            msg=\"Resource type [resourceType] does not exist\",\n        )\n    url = await assemble_auth_url(request_path=\"/v2/aiui/cbm/document/parse\")\n    return await request(post_body=post_body, url=url, **kwargs)\n\n\nasync def chunk_split(\n    document: Any,\n    length_range: Optional[List[int]] = None,\n    overlap: Optional[int] = None,","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/infra/aiui/aiui.py#L118-L154","documentation":"document_parse in core/knowledge/infra/aiui/aiui.py parses documents via the AIUI CBM API. When resource_type == 0 (file mode), it extracts the file extension from the URL with get_file_extension_from_url; if the extension comes back empty, it raises CustomException(CodeEnum.ParameterInvalid) because it cannot determine the fileType to send to AIUI.","triggerScenarios":"Calling document_parse(file_url, resource_type=0) where the file_url has no parseable extension — e.g. a presigned/query-only URL with no extension, a bare filename, a URL ending in '/', or an extension pattern get_file_extension_from_url does not recognize.","commonSituations":"Passing MinIO/S3 presigned URLs whose path lacks an extension; URLs with long query strings where the extractor fails; uploading files stored under hashed names without extensions; resource_type passed as 0 (file) while the caller actually has a plain web URL (should be 1).","solutions":["Verify resource_type: if file_url is a web page or hosted link rather than a raw file, call with resource_type=1 so fileType='url' is used.","Ensure the URL path contains a recognized file extension (pdf, docx, jpg, png, etc.); re-upload or re-generate the object with a proper extension.","Check get_file_extension_from_url to confirm it handles your URL form (query strings, encoded characters) and fix or extend the extractor if needed.","Strip or normalize the query string before extracting the extension, or pass the extension explicitly if the API surface allows."],"exampleFix":"// before\nresult = await document_parse(presigned_url, resource_type=0)\n// after\nif get_file_extension_from_url(presigned_url):\n    result = await document_parse(presigned_url, resource_type=0)\nelse:\n    result = await document_parse(presigned_url, resource_type=1)  # treat as url","handlingStrategy":"validation","validationCode":"from core... import get_file_extension_from_url\next = get_file_extension_from_url(file_url)\nif resource_type == 0 and not ext:\n    raise ValueError(f\"file_url has no detectable extension: {file_url}\")","typeGuard":"def has_file_extension(url: str) -> bool:\n    return bool(get_file_extension_from_url(url))","tryCatchPattern":"try:\n    result = await document_parse(file_url, resource_type=0)\nexcept CustomException as e:\n    if \"File type retrieval failed\" in str(e):\n        result = await document_parse(file_url, resource_type=1)\n    else:\n        raise","preventionTips":["Always store objects under keys with real file extensions","Prefer resource_type=1 for arbitrary web URLs","Unit-test get_file_extension_from_url against your real URL shapes (query strings, encoded chars)"],"tags":["parameter-validation","document-parsing","aiui"],"backgroundTag":"missing-required-argument","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}