SonarSource/sonarqube · error · IllegalStateException
Can not read file
Error message
Can not read file
What it means
MutableDumpReaderImpl.metadata() parses the dump's metadata protobuf file from the task's temp directory. If the file exists but cannot be read/parsed (IOException from FileInputStream or protobuf parseFrom), it wraps the IOException in an IllegalStateException naming the file. This indicates the dump on disk is unreadable or corrupt.
Source
Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/MutableDumpReaderImpl.java:76
public File zipFile() {
checkState(zipFile != null, "Project dump file has not been set");
return zipFile;
}
@Override
public File tempRootDir() {
checkState(tempRootDir != null, "Dump file has not been extracted");
return tempRootDir;
}
@Override
public ProjectDump.Metadata metadata() {
File file = new File(tempRootDir(), METADATA.filename());
checkState(file.exists(), "Missing metadata file: %s", file);
try (FileInputStream input = FILES2.openInputStream(file)) {
return PROTOBUF2.parseFrom(METADATA.parser(), input);
} catch (IOException e) {
throw new IllegalStateException("Can not read file " + file, e);
}
}
@Override
public <M extends Message> MessageStream<M> stream(DumpElement<M> elt) {
File file = new File(tempRootDir(), elt.filename());
checkState(file.exists(), "Missing file: %s", file);
InputStream input = FILES2.openInputStream(file);
return new MessageStreamImpl<>(input, elt.parser());
}
}
View on GitHub (pinned to 184c821202)
Solutions
- Re-run the CE task so a fresh, complete dump is produced
- Verify the dump directory contents are complete and not truncated (compare file sizes/checksums)
- Check disk space and filesystem health on the CE worker temp directory
- If dumps are on network storage, verify it is mounted and stable during task execution
Defensive patterns
Strategy: try-catch
Validate before calling
File meta = new File(tempRootDir(), "metadata.pb");
if (!meta.isFile() || meta.length() == 0) {
throw new IllegalStateException("Dump metadata missing or empty: " + meta);
} Try / catch
try {
ProjectDump.Metadata md = reader.metadata();
} catch (IllegalStateException e) {
// dump corrupt/incomplete — request a fresh export instead of retrying parse
LOGGER.error("Dump unreadable at {}: {}", tempRootDir(), e.getCause(), e);
} Prevention
- Never move or prune the dump directory while a CE task is running
- Monitor disk space so dumps are not truncated
- Keep dumps on local or stable storage, not flaky network mounts
- Re-export rather than retry parsing a known-truncated dump
When it happens
Trigger: METADATA file exists at tempRootDir() but FileInputStream open or PROTOBUF2.parseFrom throws IOException — truncated/corrupt dump file, file deleted between the exists() check and the read, or permission/I/O error while reading.
Common situations: A project dump truncated by a full disk or killed CE process; a dump zip extracted partially; the dump was moved/rotated while the task was running; NFS or network storage briefly unavailable.
Understand the failure class
Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.
Related errors
- Analysis Failed. --------------------- REASON: Potential Out
- Report contains a file with language '%s' but no matching qu
- Analysis report %s part %s is missing in database
- Fail to traverse file:
- No cache entry found for key:
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/36bdc295579ad4de.
Report an issue: GitHub.