{"record":{"id":"6c43fb3bd86b7fef","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-create-temp-directory-for-converter","errorCode":null,"errorMessage":"Failed to create temp directory for converter","messagePattern":"Failed to create temp directory for converter","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/tool/multimodal/MultimodalToolCallResultConverter.java","lineNumber":84,"sourceCode":"\t/**\n\t * Default constructor for {@code @Tool(resultConverter = MultimodalToolCallResultConverter.class)}.\n\t * Uses {@link OutputFormat#url}.\n\t */\n\tpublic MultimodalToolCallResultConverter() {\n\t\tthis(OutputFormat.url);\n\t}\n\n\t/**\n\t * Constructor with configurable output format.\n\t * @param outputFormat url (model-friendly) or base64 (inline for client)\n\t */\n\tpublic MultimodalToolCallResultConverter(OutputFormat outputFormat) {\n\t\tthis.outputFormat = outputFormat != null ? outputFormat : OutputFormat.url;\n\t\ttry {\n\t\t\tthis.tempDir = Files.createTempDirectory(\"multimodal-converter-\");\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new IllegalStateException(\"Failed to create temp directory for converter\", e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic String convert(@Nullable Object result, @Nullable Type returnType) {\n\t\tif (result instanceof ToolMultimodalResult multimodal) {\n\t\t\treturn toStructuredJson(multimodal);\n\t\t}\n\t\treturn DEFAULT_CONVERTER.convert(result, returnType);\n\t}\n\n\tprivate String toStructuredJson(ToolMultimodalResult result) {\n\t\tMap<String, Object> map = new LinkedHashMap<>();\n\t\tif (result.text() != null && !result.text().isBlank()) {\n\t\t\tmap.put(\"text\", result.text());\n\t\t}\n\t\tif (result.media() != null && !result.media().isEmpty()) {\n\t\t\tList<Map<String, Object>> mediaList = new ArrayList<>();","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/tool/multimodal/MultimodalToolCallResultConverter.java#L66-L102","documentation":"The MultimodalToolCallResultConverter constructor creates a temp directory (Files.createTempDirectory) to store converted multimodal artifacts. If the filesystem refuses (IOException), it throws IllegalStateException \"Failed to create temp directory for converter\", so the converter cannot function at all.","triggerScenarios":"Files.createTempDirectory fails because java.io.tmpdir is not writable, is full, or points to a nonexistent/nonexistent-permission location; restrictive SecurityManager or sandboxed container filesystem.","commonSituations":"Read-only /tmp in containers, disk-full on the host, misconfigured -Djava.io.tmpdir, Kubernetes pods with emptyDir quota exhausted.","solutions":["Check that java.io.tmpdir exists and is writable by the process user (touch a file there).","Free disk space or increase tmp volume size.","Set -Djava.io.tmpdir=/path/writable to a valid writable directory.","Fix container security context / readOnlyRootFilesystem settings to allow temp writes."],"exampleFix":"// before (JVM options)\njava -Djava.io.tmpdir=/nonexistent -jar app.jar\n// after\njava -Djava.io.tmpdir=/var/tmp/writable -jar app.jar","handlingStrategy":"validation","validationCode":"Path tmp = Path.of(System.getProperty(\"java.io.tmpdir\"));\nif (!Files.isDirectory(tmp) || !Files.isWritable(tmp)) { throw new IllegalStateException(\"tmpdir not writable: \" + tmp); }","typeGuard":null,"tryCatchPattern":"try { new MultimodalToolCallResultConverter(OutputFormat.url); } catch (IllegalStateException e) { log.error(\"tmpdir setup failed\", e.getCause()); }","preventionTips":["Verify java.io.tmpdir is writable at startup","Monitor tmp disk usage","Avoid read-only root filesystems without a writable tmp mount","Set explicit -Djava.io.tmpdir in containers"],"tags":["filesystem","temp-directory","initialization","io"],"backgroundTag":"module-init-failed","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"}