{"record":{"id":"ca1bd4992cc3423e","repo":"SonarSource/sonarqube","slug":"metadata-is-missing","errorCode":null,"errorMessage":"Metadata is missing","messagePattern":"Metadata is missing","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/DumpWriterImpl.java","lineNumber":82,"sourceCode":"      PROTOBUF2.writeTo(metadata, output);\n      metadataWritten.set(true);\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Can not write to file \" + file, e);\n    }\n  }\n\n  @Override\n  public <M extends Message> StreamWriter<M> newStreamWriter(DumpElement<M> elt) {\n    checkNotPublished();\n    File file = new File(rootDir, elt.filename());\n    return StreamWriterImpl.create(file);\n  }\n\n  @Override\n  public void publish() {\n    checkNotPublished();\n    if (!metadataWritten.get()) {\n      throw new IllegalStateException(\"Metadata is missing\");\n    }\n    File zip = tempFolder.newFile();\n    FILES2.zipDir(rootDir, zip);\n\n    File targetZip = projectExportDumpFS.exportDumpOf(descriptor);\n    FILES2.deleteIfExists(targetZip);\n    FILES2.moveFile(zip, targetZip);\n    FILES2.deleteIfExists(rootDir);\n    LoggerFactory.getLogger(getClass()).atInfo()\n      .addArgument(humanReadableByteCountSI(sizeOf(targetZip)))\n      .addArgument(targetZip.getAbsolutePath())\n      .log(\"Dump file published | size={} | path={}\");\n    published.set(true);\n  }\n\n  private void checkNotPublished() {\n    if (published.get()) {\n      throw new IllegalStateException(\"Dump is already published\");","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/DumpWriterImpl.java#L64-L100","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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()"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// publish only after metadata was written\nif (!metadataStepSucceeded) { throw new IllegalStateException(\"skip publish: metadata not written\"); }","typeGuard":null,"tryCatchPattern":"try { writer.publish(); } catch (IllegalStateException e) { logger.error(\"Publish aborted: metadata missing\", e); /* discard partial dump */ }","preventionTips":["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"],"tags":["sonarqube","project-export","state","missing-metadata"],"backgroundTag":"invalid-state-transition","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"}