{"record":{"id":"35a5714b7c60ebee","repo":"SonarSource/sonarqube","slug":"could-not-save-scanner-report-to-temp-file","errorCode":null,"errorMessage":"Could not save scanner report to temp file","messagePattern":"Could not save scanner report to temp file","errorType":"exception","errorClass":"IllegalStateException","httpStatus":500,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java","lineNumber":277,"sourceCode":"\n      return splitFile(tempFile, sourceSize, reportPartMaxSizeBytes, dbSession, submit);\n    } finally {\n      deleteTempFile(tempFile);\n    }\n  }\n\n  @VisibleForTesting\n  long getReportMaxSizeBytes() {\n    return configuration.getInt(REPORT_PART_MAX_SIZE_MBYTES)\n      .map(mBytes -> mBytes * 1024 * 1024)\n      .orElse(450 * 1024 * 1024);\n  }\n\n  private static void writeReportToTempFile(InputStream reportInput, File tempFile) {\n    try {\n      Files.copy(reportInput, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Could not save scanner report to temp file\", e);\n    }\n  }\n\n  private static long getSourceSize(File tempFile) {\n    try {\n      return Files.size(tempFile.toPath());\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Could not check the size of the report temp file\", e);\n    }\n  }\n\n  public int splitFile(File bigFile, long sourceSize, long reportPartMaxSizeBytes, DbSession dbSession, CeTaskSubmit.Builder submit) {\n    int position = 0;\n    LOGGER.debug(\"Splitting report file {} of size {}\", bigFile.toPath(), sourceSize);\n    try (RandomAccessFile sourceFile = new RandomAccessFile(bigFile, \"r\");\n         FileChannel sourceChannel = sourceFile.getChannel()) {\n\n      final long numSplits = sourceSize / reportPartMaxSizeBytes;","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java#L259-L295","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// sonar.properties\n// before\ncat: /tmp on 95% full volume\n// after\nsonar.web.javaAdditionalOpts=-Djava.io.tmpdir=/var/sonarqube/temp","handlingStrategy":"retry","validationCode":"long usable = Files.getFileStore(Paths.get(System.getProperty(\"java.io.tmpdir\"))).getUsableSpace();\nif (usable < reportLength * 2L) throw new IllegalStateException(\"insufficient temp disk space\");","typeGuard":null,"tryCatchPattern":"try { submit(reportStream); } catch (ServerErrorException e) if (e.message.contains(\"temp file\")) { alertDiskSpace(); }","preventionTips":["Monitor free space on java.io.tmpdir","Point tmpdir to a dedicated durable volume","Exclude tmpdir from aggressive cleaners"],"tags":["java","sonarqube","io","temp-file"],"backgroundTag":"file-write-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}