{"record":{"id":"9cde72527e330a60","repo":"iflytek/astron-agent","slug":"8329-toolbox-export-error","errorCode":"8329","errorMessage":"toolbox.export.error","messagePattern":"toolbox\\.export\\.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":2256,"sourceCode":"\n                // Convert JSON string to object tree, then write to YAML\n                JsonNode jsonNode = jsonMapper.readTree(jsonString);\n                String yamlString = yamlMapper.writeValueAsString(jsonNode);\n                data = yamlString.getBytes(StandardCharsets.UTF_8);\n            } else {\n                // JSON file\n                response.setContentType(\"application/json; charset=UTF-8\");\n                response.setHeader(\"Content-Disposition\", \"attachment; filename=\\\"export.json\\\"\");\n                data = JSONObject.toJSONString(toolBoxExportVo).getBytes(StandardCharsets.UTF_8);\n            }\n            // Set content length (important)\n            response.setContentLength(data.length);\n            // Write byte array directly\n            os.write(data);\n            os.flush();\n        } catch (Exception ex) {\n            log.error(\"Export failed\", ex);\n            throw new BusinessException(ResponseEnum.TOOLBOX_EXPORT_ERROR);\n        }\n    }\n\n    /**\n     * Import tool from JSON or YAML file\n     *\n     * @param file Uploaded file\n     * @return ToolBoxExportVo\n     */\n    public Object importTool(org.springframework.web.multipart.MultipartFile file) {\n        try {\n            // Check file type\n            String fileName = file.getOriginalFilename();\n            ObjectMapper jsonMapper = new ObjectMapper();\n            ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());\n\n            if (fileName == null) {\n                throw new BusinessException(ResponseEnum.TOOLBOX_IMPORT_FILE_NAME_NULL);","sourceCodeStart":2238,"sourceCodeEnd":2274,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java#L2238-L2274","documentation":"TOOLBOX_EXPORT_ERROR (code 8329) wraps any exception raised while exporting a tool: building the export VO, serializing it, or writing bytes to the HTTP response output stream. The catch-all logs the root cause and rethrows as a BusinessException so the client gets a uniform error.","triggerScenarios":"Export fails because serialization of the tool to JSON/YAML throws, or writing to the servlet OutputStream throws (client disconnected, broken pipe, response already committed).","commonSituations":"Client cancels the download mid-stream; container response buffer issues with large exports; data in the tool row that the export mapper cannot serialize.","solutions":["Check the server log for the logged root cause under 'Export failed'","Retry the export with a stable network connection / intact client","Inspect the tool's stored data for values that break serialization and fix them"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { byte[] data = toolBoxApi.export(toolId); } catch (BusinessException e) { if (e.getCode() == 8329) { /* retry or surface export failure with server log reference */ } else throw e; }","preventionTips":["Keep the HTTP connection alive until the download completes","Check server logs for the underlying 'Export failed' cause when it recurs","Validate tool data integrity after direct DB edits that may break serialization"],"tags":["java","spring-boot","export","io","toolbox"],"backgroundTag":"file-write-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"}