iflytek/astron-agent · error · BusinessException
8330
8330
Error message
toolbox.import.file.name.null
What it means
TOOLBOX_IMPORT_FILE_NAME_NULL (code 8330) is thrown when the uploaded MultipartFile's getOriginalFilename() returns null. The service needs the filename to decide whether the file is YAML (.yaml/.yml) or JSON (.json), so an unnamed file cannot be routed to a parser.
Solutions
- Send the multipart part with a proper filename ending in .yaml/.yml or .json
- In test code, pass a filename when constructing the MockMultipartFile
- Fix the client so the file's original name is preserved in the upload
Example fix
// before
new MockMultipartFile("file", null, "application/json", bytes)
// after
new MockMultipartFile("file", "tool.json", "application/json", bytes) Defensive patterns
Strategy: validation
Validate before calling
if (file == null || file.getOriginalFilename() == null || file.getOriginalFilename().isBlank()) { throw new IllegalArgumentException("uploaded file must have a filename"); } Type guard
boolean hasFileName(MultipartFile f) { return f != null && f.getOriginalFilename() != null && !f.getOriginalFilename().isEmpty(); } Try / catch
try { toolBoxApi.importTool(file); } catch (BusinessException e) { if (e.getCode() == 8330) { /* prompt user to re-upload with a named file */ } else throw e; } Prevention
- Always set a filename when constructing multipart parts in tests/scripts
- Avoid proxies/custom clients that strip Content-Disposition filenames
- Validate the upload client sends originalFilename
When it happens
Trigger: Posting a multipart import request where the file part has no filename, e.g. programmatically built MultipartFile without a filename, or a client that omits the filename in Content-Disposition.
Common situations: Scripts or tests constructing MockMultipartFile/ByteArrayMultipartFile without setting a name; proxies or custom HTTP clients stripping the filename header.
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
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/c1f5f10c3f583eb8.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java:2274
throw new BusinessException(ResponseEnum.TOOLBOX_EXPORT_ERROR);
}
}
/**
* Import tool from JSON or YAML file
*
* @param file Uploaded file
* @return ToolBoxExportVo
*/
public Object importTool(org.springframework.web.multipart.MultipartFile file) {
try {
// Check file type
String fileName = file.getOriginalFilename();
ObjectMapper jsonMapper = new ObjectMapper();
ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
if (fileName == null) {
throw new BusinessException(ResponseEnum.TOOLBOX_IMPORT_FILE_NAME_NULL);
}
String lowerName = fileName.toLowerCase();
ToolBoxExportVo vo;
if (lowerName.endsWith(".yaml") || lowerName.endsWith(".yml")) {
// YAML -> ToolBoxExportVo
vo = yamlMapper.readValue(file.getInputStream(), ToolBoxExportVo.class);
} else if (lowerName.endsWith(".json")) {
// JSON -> ToolBoxExportVo
vo = jsonMapper.readValue(file.getInputStream(), ToolBoxExportVo.class);
} else {
throw new BusinessException(ResponseEnum.TOOLBOX_IMPORT_FILE_FORMAT_ERROR);
}
return vo;
} catch (Exception ex) {
log.error("Import failed", ex);
if (ex instanceof BusinessException) {View on GitHub (pinned to 5e758547a8)