SonarSource/sonarqube · error · IllegalStateException
Could not save scanner report to temp file
Error message
Could not save scanner report to temp file
What it means
ReportSubmitter.writeReportToTempFile streams the uploaded scanner report into a temporary file before splitting it into DB parts. Any IOException while copying (disk full, missing temp dir, permissions) is wrapped in this IllegalStateException. It indicates a server-side storage problem, not a bad report.
Source
Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java:277
return splitFile(tempFile, sourceSize, reportPartMaxSizeBytes, dbSession, submit);
} finally {
deleteTempFile(tempFile);
}
}
@VisibleForTesting
long getReportMaxSizeBytes() {
return configuration.getInt(REPORT_PART_MAX_SIZE_MBYTES)
.map(mBytes -> mBytes * 1024 * 1024)
.orElse(450 * 1024 * 1024);
}
private static void writeReportToTempFile(InputStream reportInput, File tempFile) {
try {
Files.copy(reportInput, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new IllegalStateException("Could not save scanner report to temp file", e);
}
}
private static long getSourceSize(File tempFile) {
try {
return Files.size(tempFile.toPath());
} catch (IOException e) {
throw new IllegalStateException("Could not check the size of the report temp file", e);
}
}
public int splitFile(File bigFile, long sourceSize, long reportPartMaxSizeBytes, DbSession dbSession, CeTaskSubmit.Builder submit) {
int position = 0;
LOGGER.debug("Splitting report file {} of size {}", bigFile.toPath(), sourceSize);
try (RandomAccessFile sourceFile = new RandomAccessFile(bigFile, "r");
FileChannel sourceChannel = sourceFile.getChannel()) {
final long numSplits = sourceSize / reportPartMaxSizeBytes;View on GitHub (pinned to 184c821202)
Solutions
- Free disk space on the volume backing java.io.tmpdir
- Verify the temp directory exists and the SonarQube process user can write to it
- Set java.io.tmpdir (or SONAR_WEB_JAVAADDITIONALOPTS -Djava.io.tmpdir=...) to a durable writable path
- Retry the submission after fixing storage; check server logs for the wrapped IOException
Example fix
// sonar.properties // before cat: /tmp on 95% full volume // after sonar.web.javaAdditionalOpts=-Djava.io.tmpdir=/var/sonarqube/temp
Defensive patterns
Strategy: retry
Validate before calling
long usable = Files.getFileStore(Paths.get(System.getProperty("java.io.tmpdir"))).getUsableSpace();
if (usable < reportLength * 2L) throw new IllegalStateException("insufficient temp disk space"); Try / catch
try { submit(reportStream); } catch (ServerErrorException e) if (e.message.contains("temp file")) { alertDiskSpace(); } Prevention
- Monitor free space on java.io.tmpdir
- Point tmpdir to a dedicated durable volume
- Exclude tmpdir from aggressive cleaners
When it happens
Trigger: Files.copy(reportInput, tempFile) fails: temp directory deleted or not writable, disk quota/full filesystem, or the client aborted the stream mid-upload causing an IO error while reading the input.
Common situations: Full /tmp partition on the SonarQube server; sonar.path.data or java.io.tmpdir pointing to an unwritable or cleaned location; very large reports exhausting disk; interrupted network upload.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Could not check the size of the report temp file
- Failed to split report for task ${uuid}
- Could not save report ${uuid} part ${partNumber} file to dat
- %s for request [%s]: [%s]
- Fail to write into file:
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/35a5714b7c60ebee.
Report an issue: GitHub.