{"record":{"id":"574f9efac1a1ee9d","repo":"elunez/eladmin","slug":"error-574f9e","errorCode":null,"errorMessage":"打包失败","messagePattern":"打包失败","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java","lineNumber":202,"sourceCode":"        if (genConfig.getId() == null) {\n            throw new BadRequestException(CONFIG_MESSAGE);\n        }\n        List<Map<String, Object>> genList = GenUtil.preview(columns, genConfig);\n        return new ResponseEntity<>(genList, HttpStatus.OK);\n    }\n\n    @Override\n    public void download(GenConfig genConfig, List<ColumnInfo> columns, HttpServletRequest request, HttpServletResponse response) {\n        if (genConfig.getId() == null) {\n            throw new BadRequestException(CONFIG_MESSAGE);\n        }\n        try {\n            File file = new File(GenUtil.download(columns, genConfig));\n            String zipPath = file.getPath() + \".zip\";\n            ZipUtil.zip(file.getPath(), zipPath);\n            FileUtil.downloadFile(request, response, new File(zipPath), true);\n        } catch (IOException e) {\n            throw new BadRequestException(\"打包失败\");\n        }\n    }\n}\n","sourceCodeStart":184,"sourceCodeEnd":206,"githubUrl":"https://github.com/elunez/eladmin/blob/55fbf705956949697dbd68bf9003776609d3d029/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java#L184-L206","documentation":"GeneratorServiceImpl.download catches IOException around GenUtil.download + ZipUtil.zip + FileUtil.downloadFile and rethrows as BadRequestException('打包失败'). It means the server failed to render templates to a temp dir, zip it, or stream the zip to the response — an I/O or environment problem, not a config problem.","triggerScenarios":"type=2 download when the temp/output directory is not writable, disk is full while zipping, the response stream is aborted by the client, or GenUtil.download cannot create the generation directory.","commonSituations":"Service account lacking write permission on the working/temp dir (common when running under systemd with ProtectSystem, or in Docker read-only layers); low disk space; client cancelling the download mid-stream; eladmin temp dir removed concurrently.","solutions":["Check the server log for the underlying IOException to find the failing step (render, zip, or stream).","Ensure the process user can write to the directory GenUtil.download uses (typically the configured path or a temp dir) — chmod/chown or mount a writable volume.","Free disk space and retry the download.","Retry with a stable connection / avoid cancelling; a client abort also surfaces here."],"exampleFix":"# before: read-only container filesystem\n docker run eladmin ... (no writable tmp)\n\n# after: mount writable tmp and output volumes\n docker run -v /data/codegen:/opt/codegen -e TMPDIR=/data/tmp eladmin ...","handlingStrategy":"try-catch","validationCode":"// Pre-check temp/output writability and disk headroom before download\nFile tmp = new File(System.getProperty(\"java.io.tmpdir\"));\nif (!tmp.canWrite() || tmp.getUsableSpace() < 256L * 1024 * 1024) {\n    throw new IllegalStateException(\"tmp unwritable or low disk\");\n}\ngeneratorService.download(config, columns, request, response);","typeGuard":"boolean environmentCanZip() {\n    File tmp = new File(System.getProperty(\"java.io.tmpdir\"));\n    return tmp.canWrite() && tmp.getUsableSpace() > 100L * 1024 * 1024;\n}","tryCatchPattern":"try {\n    generatorService.download(config, columns, request, response);\n} catch (BadRequestException e) {\n    if (\"打包失败\".equals(e.getMessage())) {\n        log.error(\"zip/download IO failure for {}\", config.getTableName()); // server log has root cause\n    }\n    throw e;\n}","preventionTips":["Mount a writable tmp/output volume in containers; avoid read-only root filesystems without TMPDIR override.","Alert on low disk space on nodes that generate zips.","Don't abort downloads client-side; the server-side stream failure surfaces as 打包失败."],"tags":["code-generator","io","zip","eladmin","filesystem-permissions"],"backgroundTag":null,"analyzedSha":"55fbf705956949697dbd68bf9003776609d3d029","analyzedAt":"2026-08-14T11:56:12.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}