iflytek/astron-agent · error · BusinessException
8331
8331
Error message
toolbox.import.error
What it means
TOOLBOX_IMPORT_ERROR (code 8331) is the generic catch-all for import failures that are not BusinessException: Jackson/YAML parse errors, mapping to ToolBoxExportVo failures, or persistence errors. Any non-format, non-name problem during import lands here after being logged.
Solutions
- Validate the file parses and matches the ToolBoxExportVo schema before importing
- Re-export a working tool and diff against your file to find schema drift
- Check the server log line 'Import failed' for the exact Jackson exception
Example fix
// before
{"name":"tool"} // missing required export fields
// after
{"toolName":"tool","description":"...","paramList":[], ...} // full ToolBoxExportVo shape Defensive patterns
Strategy: validation
Validate before calling
// pre-validate content new ObjectMapper().readValue(file.getBytes(), ToolBoxExportVo.class); // throws before upload if schema mismatch
Try / catch
try { toolBoxApi.importTool(file); } catch (BusinessException e) { if (e.getCode() == 8331) { /* parse/validate the file locally and report the malformed field */ } else throw e; } Prevention
- Never hand-edit export files without re-validating as JSON/YAML
- Validate files against ToolBoxExportVo schema before import
- Keep export/import schema versions in sync across releases
When it happens
Trigger: Uploading a .json or .yaml file whose content does not match the ToolBoxExportVo schema (missing fields, wrong types, malformed JSON/YAML), or an I/O error reading the stream.
Common situations: Hand-edited export files with invalid JSON; YAML from an older/newer schema version that no longer maps; files corrupted in transit or truncated uploads.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/de3349dcd38e3245.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java:2295
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) {
throw (BusinessException) ex;
}
throw new BusinessException(ResponseEnum.TOOLBOX_IMPORT_ERROR);
}
}
}
View on GitHub (pinned to 5e758547a8)