iflytek/astron-agent · warning · CustomException
23601
23601
Error message
File name cannot be empty
What it means
upload_file in the flow file API rejects an UploadFile whose filename is empty/None (code 23601, FILE_INVALID_ERROR). After reading bytes and running file_service.check, it validates the filename because the extension is derived from filename.split('.')[-1] and an empty name cannot produce a valid storage key.
Solutions
- Ensure the multipart part includes a filename, e.g. curl -F 'file=@report.pdf' instead of raw body upload.
- Validate the filename client-side before upload and reject empty names with a friendly message.
- If uploading programmatically, set the filename explicitly in your HTTP client's form builder.
- Sanitize/derive a fallback filename server-side before the check if empty names are acceptable in your flow.
Example fix
# before curl --data-binary @report.pdf http://host/api/v1/flow/file/upload # after curl -F 'file=@report.pdf' http://host/api/v1/flow/file/upload
Defensive patterns
Strategy: validation
Validate before calling
if not file or not getattr(file, 'filename', None):
raise ValueError("file must have a non-empty filename before upload") Type guard
def has_filename(file) -> bool:
return bool(getattr(file, 'filename', None)) Try / catch
try:
await upload_file(file)
except CustomException as e:
if e.code == CodeEnum.FILE_INVALID_ERROR.code:
show_user_error("Please select a valid file with a name")
else:
raise Prevention
- Always upload via multipart form fields with an explicit filename (curl -F, FormData)
- Validate filename presence/extension client-side before sending
- Check Content-Disposition is not stripped by proxies/gateways
When it happens
Trigger: POSTing multipart/form-data to the flow file upload endpoint with a file part lacking a filename (no filename in Content-Disposition), or with filename set to empty string.
Common situations: HTTP clients that send raw bytes without a proper multipart filename field; programmatic uploads (curl --data-binary instead of -F); generated file parts from tests/scripts omitting the filename; proxies stripping Content-Disposition metadata.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/da7d4af4a810b507.
Report an issue: GitHub.
Appendix: source
Thrown at core/workflow/api/v1/flow/file.py:49
async def upload_file(
x_consumer_username: Annotated[str, Header()], file: UploadFile = File(...)
) -> JSONResponse:
"""
Upload a single file to the workflow system.
:param x_consumer_username: Consumer username from header
:param file: File to upload
:return: Response with uploaded file URL
"""
app_id = x_consumer_username
m = Meter(app_id)
span = Span(app_id=app_id)
with span.start() as span_context:
try:
contents = await file.read()
file_service.check(file, contents, span_context)
if not file.filename:
raise CustomException(
err_code=CodeEnum.FILE_INVALID_ERROR,
err_msg="File name cannot be empty",
)
extension = file.filename.split(".")[-1].lower()
file_url = await get_oss_service().upload_file_async(
f"{str(uuid.uuid4())}.{extension}", contents
)
m.in_success_count()
return Resp.success(data={"url": file_url}, sid=span_context.sid)
except CustomException as e:
span_context.record_exception(e)
m.in_error_count(e.code, span=span_context)
return Resp.error(e.code, e.message, span_context.sid)
except Exception as e:
span_context.record_exception(e)
m.in_error_count(CodeEnum.FILE_STORAGE_ERROR.code, span=span_context)
return Resp.error(
CodeEnum.FILE_STORAGE_ERROR.code,View on GitHub (pinned to 5e758547a8)