iflytek/astron-agent · error · CustomException
ParameterInvalid
ParameterInvalid
Error message
File type retrieval failed: {file_url} What it means
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.
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.
Example fix
// before
result = await document_parse(presigned_url, resource_type=0)
// after
if get_file_extension_from_url(presigned_url):
result = await document_parse(presigned_url, resource_type=0)
else:
result = await document_parse(presigned_url, resource_type=1) # treat as url Defensive patterns
Strategy: validation
Validate before calling
from core... import get_file_extension_from_url
ext = get_file_extension_from_url(file_url)
if resource_type == 0 and not ext:
raise ValueError(f"file_url has no detectable extension: {file_url}") Type guard
def has_file_extension(url: str) -> bool:
return bool(get_file_extension_from_url(url)) Try / catch
try:
result = await document_parse(file_url, resource_type=0)
except CustomException as e:
if "File type retrieval failed" in str(e):
result = await document_parse(file_url, resource_type=1)
else:
raise Prevention
- 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)
When it happens
Trigger: 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.
Common situations: 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).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- PARAMETER_ERROR
- REPO_FILE_SLICE_RANGE_16_1024
- REPO_KNOWLEDGE_ALL_EMBEDDING_FAILED
- AIUI_RAGError
- ParameterCheckException
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/6ce30395b19e3e96.
Report an issue: GitHub.
Appendix: source
Thrown at core/knowledge/infra/aiui/aiui.py:136
Parse results
Raises:
CustomException: When file type retrieval fails or resource type does not exist
"""
post_body = {"file": file_url, "fileType": "pdf", "useLayout": False}
if resource_type == 0:
image_extensions = {"jpg", "jpeg", "png", "bmp"}
file_extension = get_file_extension_from_url(file_url)
if check_not_empty(file_extension):
post_body["fileType"] = file_extension
post_body["useLayout"] = file_extension.upper() == "PDF"
if file_extension.lower() in image_extensions:
post_body["fileType"] = "image"
else:
raise CustomException(
e=CodeEnum.ParameterInvalid,
msg=f"File type retrieval failed: {file_url}",
)
elif resource_type == 1:
post_body["fileType"] = "url"
else:
raise CustomException(
e=CodeEnum.ParameterInvalid,
msg="Resource type [resourceType] does not exist",
)
url = await assemble_auth_url(request_path="/v2/aiui/cbm/document/parse")
return await request(post_body=post_body, url=url, **kwargs)
async def chunk_split(
document: Any,
length_range: Optional[List[int]] = None,
overlap: Optional[int] = None,View on GitHub (pinned to 5e758547a8)