{"record":{"id":"8ba875cfaeb1cd71","repo":"OpenAPITools/openapi-generator","slug":"cannot-access-tmp-folder","errorCode":null,"errorMessage":"Cannot access tmp folder","messagePattern":"Cannot access tmp folder","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"critical","filePath":"modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java","lineNumber":187,"sourceCode":"            try {\n                new File(outputFolder).delete();\n            } catch (Exception e) {\n                LOGGER.error(\"unable to delete output folder \" + outputFolder, e);\n            }\n        } catch (Exception e) {\n            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"Unable to build target: \" + e.getMessage(), e);\n        }\n        return outputFilename;\n    }\n\n    private static File getTmpFolder() {\n        try {\n            File outputFolder = Files.createTempDirectory(\"codegen-tmp\").toFile();\n            outputFolder.deleteOnExit();\n            return outputFolder;\n        } catch (Exception e) {\n            e.printStackTrace();\n            throw new RuntimeException(\"Cannot access tmp folder\");\n        }\n    }\n}\n","sourceCodeStart":169,"sourceCodeEnd":191,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java#L169-L191","documentation":"Thrown when Files.createTempDirectory(\"codegen-tmp\") fails (Generator.java:180-188) — the JVM cannot create a directory under java.io.tmpdir. It escapes as a plain RuntimeException (not a ResponseStatusException), so it surfaces as an HTTP 500 on every generate call. Because each generation allocates a fresh temp dir first, a broken tmp location takes the whole generate feature down.","triggerScenarios":"java.io.tmpdir points to a missing or read-only path (containers with a read-only root filesystem and no tmpfs on /tmp); disk full / tmpfs size limit hit; service user lacks write permission on the tmp dir; security manager or SELinux blocking creation.","commonSituations":"Docker/Kubernetes images with readOnlyRootFilesystem: true and no --tmpfs /tmp; containers whose /tmp tmpfs is sized for small files while generated SDKs need tens of MB; misconfigured -Djava.io.tmpdir pointing at an unmounted volume.","solutions":["Verify the service can write to its tmp dir: ls -ld $TMPDIR and touch as the service user","In containers, mount a writable volume or tmpfs at /tmp (e.g. docker run --tmpfs /tmp:rw,size=512m)","Free disk space or raise the tmpfs size limit on the host","As a last resort, point java.io.tmpdir at a known-writable volume via -Djava.io.tmpdir=/var/tmp/openapi-gen"],"exampleFix":"# before: container with read-only root fs\n docker run --read-only my-openapi-generator-online   # every generate -> 500 Cannot access tmp folder\n\n# after\n docker run --read-only --tmpfs /tmp:rw,size=512m my-openapi-generator-online","handlingStrategy":"try-catch","validationCode":"// health check for self-hosted instances: can this JVM create its temp dir?\ntry {\n    Files.createTempDirectory(\"codegen-tmp-probe\").toFile().delete();\n} catch (IOException e) {\n    throw new IllegalStateException(\"java.io.tmpdir not writable: \" + System.getProperty(\"java.io.tmpdir\"), e);\n}","typeGuard":null,"tryCatchPattern":"catch (HttpServerErrorException e) {\n    // 500 on EVERY generate usually means server tmp is broken — no client-side fix, alert the operator\n    alert(\"openapi-generator-online cannot write tmp; check java.io.tmpdir / disk / container tmpfs\");\n    throw e;\n}","preventionTips":["Run the tmp-probe check in container health checks/startup probes","With readOnlyRootFilesystem, always add --tmpfs /tmp:rw,size=512m (or mount a writable volume)","Monitor free space on the tmp filesystem — generation spikes usage"],"tags":["http-500","tmp-dir","filesystem-permissions","containerization","openapi-generator-online"],"backgroundTag":"temp-dir-not-writable","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}