{"record":{"id":"d16034343dddc40e","repo":"elunez/eladmin","slug":"error-d16034","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":178,"sourceCode":"            }\n        }\n    }\n\n    @Override\n    public void save(List<ColumnInfo> columnInfos) {\n        columnInfoRepository.saveAll(columnInfos);\n    }\n\n    @Override\n    public void generator(GenConfig genConfig, List<ColumnInfo> columns) {\n        if (genConfig.getId() == null) {\n            throw new BadRequestException(CONFIG_MESSAGE);\n        }\n        try {\n            GenUtil.generatorCode(columns, genConfig);\n        } catch (IOException e) {\n            log.error(e.getMessage(), e);\n            throw new BadRequestException(\"生成失败，请手动处理已生成的文件\");\n        }\n    }\n\n    @Override\n    public ResponseEntity<Object> preview(GenConfig genConfig, List<ColumnInfo> columns) {\n        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 {","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/elunez/eladmin/blob/55fbf705956949697dbd68bf9003776609d3d029/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java#L160-L196","documentation":"GeneratorServiceImpl.generator wraps GenUtil.generatorCode in a try/catch; an IOException while writing generated templates to disk is logged and rethrown as BadRequestException('生成失败，请手动处理已生成的文件'). Because the writer may have emitted some files before failing, the message warns that partial output may exist.","triggerScenarios":"type=0 generation where the template engine cannot create/write files under the configured path (genConfig.getPath() + package dirs): no write permission, a read-only volume, disk full, or the output directory was deleted mid-run.","commonSituations":"Running the jar as a user without write access to /opt/app/... or the configured generation path; container with a read-only layer; disk quota exhausted; relative path resolving to an unexpected cwd.","solutions":["Check the logged IOException stack trace (log.error before the throw) to identify the exact failing path.","Grant write permission (chown/chmod) to the service user for genConfig.path and its parents, or point the path to a writable directory.","Free disk space / raise the container volume size, then retry.","Inspect the output directory for partially generated files and delete or complete them manually, as the message advises."],"exampleFix":"# before: generation path not writable\n# gen_config.path = /opt/codegen  (owned by root, app runs as 'eladmin')\n\n# after\nsudo chown -R eladmin:eladmin /opt/codegen\n# or update gen_config row to a writable path, e.g. /home/eladmin/codegen","handlingStrategy":"try-catch","validationCode":"// Verify the output location is writable before generating\nString outDir = genConfig.getPath() + \"/\" + genConfig.getPackName().replace('.', '/');\nFile f = new File(outDir);\nFiles.createDirectories(f.getParentFile().toPath());\nif (!f.getParentFile().canWrite()) throw new IllegalStateException(\"No write permission: \" + outDir);","typeGuard":"boolean canWriteTo(String path) {\n    File dir = new File(path);\n    return dir.exists() ? dir.canWrite() : dir.getAbsoluteFile().getParentFile().canWrite();\n}","tryCatchPattern":"try {\n    generatorService.generator(config, columns);\n} catch (BadRequestException e) {\n    if (e.getMessage().contains(\"生成失败\")) {\n        auditOutputDirectoryForPartialFiles(genConfig); // message warns partial files exist\n    }\n    throw e;\n}","preventionTips":["Run the service under an account with write access to the configured generation path.","Monitor disk space on the generation volume.","After any '生成失败' inspect and clean partially written files before retrying."],"tags":["code-generator","io","filesystem-permissions","eladmin"],"backgroundTag":null,"analyzedSha":"55fbf705956949697dbd68bf9003776609d3d029","analyzedAt":"2026-08-14T11:56:12.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}