{"record":{"id":"11da1233001655f1","repo":"alibaba/spring-ai-alibaba","slug":"got-error-when-creating-files","errorCode":null,"errorMessage":"Got error when creating files","messagePattern":"Got error when creating files","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/generator/service/generator/agent/AgentProjectGenerator.java","lineNumber":128,"sourceCode":"\n\t\t\t\t// 覆盖写文件（自动创建/替换文件）\n\t\t\t\tFiles.writeString(filePath, template, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);\n\t\t\t}\n\t\t\tcatch (IOException e) {\n\t\t\t\tthrow new RuntimeException(\"Error processing template: \" + templateName, e);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate Path createDirectory(Path projectRoot, ProjectDescription projectDescription) {\n\t\tStringBuilder pathBuilder = new StringBuilder(\"src/main/\").append(projectDescription.getLanguage().id());\n\t\tString packagePath = projectDescription.getPackageName().replace('.', '/');\n\t\tpathBuilder.append(\"/\").append(packagePath).append(\"/graph/\");\n\t\ttry {\n\t\t\treturn Files.createDirectories(projectRoot.resolve(pathBuilder.toString()));\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new RuntimeException(\"Got error when creating files\", e);\n\t\t}\n\t}\n\n\tprivate CodeSections collectSections(Agent agent, RenderContext ctx) {\n\t\t// 递归先处理子 agent，收集子 varNames\n\t\tList<String> childVars = new ArrayList<>();\n\t\tList<CodeSections> childSections = new ArrayList<>();\n\t\tif (agent.getSubAgents() != null) {\n\t\t\tfor (Agent sub : agent.getSubAgents()) {\n\t\t\t\tCodeSections cs = collectSections(sub, ctx);\n\t\t\t\tchildSections.add(cs);\n\t\t\t\tchildVars.add(cs.getVarName());\n\t\t\t}\n\t\t}\n\n\t\t// 当前节点由 Provider 渲染\n\t\tAgentTypeProvider provider = providerRegistry.get(agent.getAgentClass());\n\t\tAgentShell shell = AgentShell.of(agent.getAgentClass(), agent.getName(), agent.getDescription(),","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/generator/service/generator/agent/AgentProjectGenerator.java#L110-L146","documentation":"AgentProjectGenerator.createDirectory() wraps any exception from Files.createDirectories() in a RuntimeException with this message. It occurs while creating src/main/<language>/<packagePath>/graph/ for the generated project. The underlying exception (e.g. FileSystemException, AccessDeniedException) is chained as the cause.","triggerScenarios":"createDirectory() (called via fileRoot) resolves a path built from the language id and package name and Files.createDirectories fails — unwritable parent, permission denied, or a path conflict (a file exists where a directory is needed).","commonSituations":"Running the generator in a read-only workspace or container; package name containing invalid path characters; leftover file at the target path from a previous run; running as a user without write permissions.","solutions":["Check the chained cause for the exact filesystem error and path","Ensure the target project root is writable by the process user (chmod/chown)","Remove any conflicting file at the target path","Verify the packageName contains only valid Java package characters"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"if (!Files.isDirectory(projectRoot) || !Files.isWritable(projectRoot)) {\n    throw new IllegalStateException(\"project root must be a writable directory\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    generator.generate(description);\n} catch (RuntimeException e) {\n    if (\"Got error when creating files\".equals(e.getMessage())) {\n        log.error(\"Directory creation failed: {}\", e.getCause());\n    }\n}","preventionTips":["Run the generator with a user that owns/has write access to the workspace","Verify packageName has no invalid path characters (dots only as separators)","Clear stale output directories or conflicting files before regenerating","In containers, mount the output volume as writable"],"tags":["io","filesystem","directory"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}