{"record":{"id":"de3349dcd38e3245","repo":"iflytek/astron-agent","slug":"8331-toolbox-import-error","errorCode":"8331","errorMessage":"toolbox.import.error","messagePattern":"toolbox\\.import\\.error","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java","lineNumber":2295,"sourceCode":"            String lowerName = fileName.toLowerCase();\n\n            ToolBoxExportVo vo;\n            if (lowerName.endsWith(\".yaml\") || lowerName.endsWith(\".yml\")) {\n                // YAML -> ToolBoxExportVo\n                vo = yamlMapper.readValue(file.getInputStream(), ToolBoxExportVo.class);\n            } else if (lowerName.endsWith(\".json\")) {\n                // JSON -> ToolBoxExportVo\n                vo = jsonMapper.readValue(file.getInputStream(), ToolBoxExportVo.class);\n            } else {\n                throw new BusinessException(ResponseEnum.TOOLBOX_IMPORT_FILE_FORMAT_ERROR);\n            }\n            return vo;\n        } catch (Exception ex) {\n            log.error(\"Import failed\", ex);\n            if (ex instanceof BusinessException) {\n                throw (BusinessException) ex;\n            }\n            throw new BusinessException(ResponseEnum.TOOLBOX_IMPORT_ERROR);\n        }\n    }\n}\n","sourceCodeStart":2277,"sourceCodeEnd":2299,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L2277-L2299","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n{\"name\":\"tool\"}  // missing required export fields\n// after\n{\"toolName\":\"tool\",\"description\":\"...\",\"paramList\":[], ...} // full ToolBoxExportVo shape","handlingStrategy":"validation","validationCode":"// pre-validate content\nnew ObjectMapper().readValue(file.getBytes(), ToolBoxExportVo.class); // throws before upload if schema mismatch","typeGuard":null,"tryCatchPattern":"try { toolBoxApi.importTool(file); } catch (BusinessException e) { if (e.getCode() == 8331) { /* parse/validate the file locally and report the malformed field */ } else throw e; }","preventionTips":["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"],"tags":["java","spring-boot","import","jackson","toolbox"],"backgroundTag":"schema-validation-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}