SonarSource/sonarqube · error · IllegalStateException
Metadata is missing
Error message
Metadata is missing
What it means
publish() finalizes the dump by zipping the dump root and copying it to the export location. A dump without metadata is structurally invalid, so if publish() is called before write(metadata) ever succeeded, an IllegalStateException "Metadata is missing" is thrown. Metadata is what identifies the dump on import.
Source
Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/DumpWriterImpl.java:82
PROTOBUF2.writeTo(metadata, output);
metadataWritten.set(true);
} catch (IOException e) {
throw new IllegalStateException("Can not write to file " + file, e);
}
}
@Override
public <M extends Message> StreamWriter<M> newStreamWriter(DumpElement<M> elt) {
checkNotPublished();
File file = new File(rootDir, elt.filename());
return StreamWriterImpl.create(file);
}
@Override
public void publish() {
checkNotPublished();
if (!metadataWritten.get()) {
throw new IllegalStateException("Metadata is missing");
}
File zip = tempFolder.newFile();
FILES2.zipDir(rootDir, zip);
File targetZip = projectExportDumpFS.exportDumpOf(descriptor);
FILES2.deleteIfExists(targetZip);
FILES2.moveFile(zip, targetZip);
FILES2.deleteIfExists(rootDir);
LoggerFactory.getLogger(getClass()).atInfo()
.addArgument(humanReadableByteCountSI(sizeOf(targetZip)))
.addArgument(targetZip.getAbsolutePath())
.log("Dump file published | size={} | path={}");
published.set(true);
}
private void checkNotPublished() {
if (published.get()) {
throw new IllegalStateException("Dump is already published");View on GitHub (pinned to 184c821202)
Solutions
- Ensure the step that calls write(metadata) runs before publish() in the step sequence
- Verify no earlier metadata-write exception was swallowed leaving the dump incomplete
- If a previous write failed, restart the whole export with a fresh DumpWriter rather than calling publish()
Defensive patterns
Strategy: validation
Validate before calling
// publish only after metadata was written
if (!metadataStepSucceeded) { throw new IllegalStateException("skip publish: metadata not written"); } Try / catch
try { writer.publish(); } catch (IllegalStateException e) { logger.error("Publish aborted: metadata missing", e); /* discard partial dump */ } Prevention
- Enforce step ordering: metadata write strictly before publish
- Fail the whole pipeline immediately when the metadata step fails; never continue to publish
- Test the pipeline with a missing metadata step to verify it fails fast
When it happens
Trigger: Calling publish() on a DumpWriterImpl whose metadataWritten flag is false — i.e. no step wrote metadata, or the metadata write failed earlier without this writer being discarded.
Common situations: Export step pipeline misconfigured so the metadata step is skipped or runs after publish; a swallowed exception during the earlier metadata write left the flag unset.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Metadata has already been written
- Dump is already published
- Ad-hoc rules export failed after processing %d rules success
- Rule Export failed after processing %d rules successfully
- Specified RuleKey '%s' is not equal to the one already regis
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/ca1bd4992cc3423e.
Report an issue: GitHub.