OpenAPITools/openapi-generator · critical · RuntimeException
Cannot access tmp folder
Error message
Cannot access tmp folder
What it means
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.
Source
Thrown at modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java:187
try {
new File(outputFolder).delete();
} catch (Exception e) {
LOGGER.error("unable to delete output folder " + outputFolder, e);
}
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Unable to build target: " + e.getMessage(), e);
}
return outputFilename;
}
private static File getTmpFolder() {
try {
File outputFolder = Files.createTempDirectory("codegen-tmp").toFile();
outputFolder.deleteOnExit();
return outputFolder;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Cannot access tmp folder");
}
}
}
View on GitHub (pinned to fcec517be3)
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
Example fix
# before: container with read-only root fs docker run --read-only my-openapi-generator-online # every generate -> 500 Cannot access tmp folder # after docker run --read-only --tmpfs /tmp:rw,size=512m my-openapi-generator-online
Defensive patterns
Strategy: try-catch
Validate before calling
// health check for self-hosted instances: can this JVM create its temp dir?
try {
Files.createTempDirectory("codegen-tmp-probe").toFile().delete();
} catch (IOException e) {
throw new IllegalStateException("java.io.tmpdir not writable: " + System.getProperty("java.io.tmpdir"), e);
} Try / catch
catch (HttpServerErrorException e) {
// 500 on EVERY generate usually means server tmp is broken — no client-side fix, alert the operator
alert("openapi-generator-online cannot write tmp; check java.io.tmpdir / disk / container tmpfs");
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- I/O error while reading file
- File not found or has expired
- File not found
- Framework is required
- Unsupported target %s supplied. %s
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/8ba875cfaeb1cd71.
Report an issue: GitHub.