{"record":{"id":"c1a89ee41f95b1a1","repo":"SonarSource/sonarqube","slug":"issue-export-failed-after-processing-d-issues-suc","errorCode":null,"errorMessage":"Issue export failed after processing %d issues successfully","messagePattern":"Issue export failed after processing (.+?) issues successfully","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java","lineNumber":89,"sourceCode":"\n  @Override\n  public void execute(Context context) {\n    MutableLong count = MutableLong.valueOf(0);\n    try (\n      StreamWriter<ProjectDump.Issue> output = dumpWriter.newStreamWriter(DumpElement.ISSUES);\n      DbSession dbSession = dbClient.openSession(false);\n      Cursor<IssueDto> issueDtoCursor = dbClient.projectExportDao()\n        .scrollIssueForExport(dbSession, projectHolder.projectDto().getUuid())) {\n      ProjectDump.Issue.Builder issueBuilder = ProjectDump.Issue.newBuilder();\n      issueDtoCursor\n        .forEach(issueDto -> {\n          ProjectDump.Issue issue = convertToIssue(issueDto, issueBuilder);\n          output.write(issue);\n          count.getAndInc();\n        });\n      LoggerFactory.getLogger(getClass()).debug(\"{} issues exported\", count.value);\n    } catch (Exception e) {\n      throw new IllegalStateException(format(\"Issue export failed after processing %d issues successfully\", count.value), e);\n    }\n  }\n\n  private ProjectDump.Issue convertToIssue(IssueDto issueDto, ProjectDump.Issue.Builder builder) {\n\n    String ruleRef = registerRule(issueDto);\n    builder\n      .clear()\n      .setRuleRef(ruleRef)\n      .setUuid(issueDto.getKee())\n      .setComponentRef(componentRepository.getRef(issueDto.getComponentUuid()))\n      .setType(issueDto.getType())\n      .setMessage(Optional.of(issueDto).map(IssueDto::getMessage).orElse(\"\"))\n      .setLine(Optional.of(issueDto).map(IssueDto::getLine).orElse(0))\n      .setChecksum(Optional.of(issueDto).map(IssueDto::getChecksum).orElse(\"\"))\n      .setStatus(Optional.of(issueDto).map(IssueDto::getStatus).orElse(\"\"))\n      .setResolution(Optional.of(issueDto).map(IssueDto::getResolution).orElse(\"\"))\n      .setSeverity(Optional.of(issueDto).map(IssueDto::getSeverity).orElse(\"\"))","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java#L71-L107","documentation":"ExportIssuesStep.execute() streams all ISSUES of the project, converting each IssueDto to a ProjectDump.Issue protobuf. Any exception in the stream (SQL error, conversion failure, IO write error) is wrapped in an IllegalStateException that reports how many issues were exported successfully before failing.","triggerScenarios":"SQLException on the scrolling issue select; convertToIssue failures (missing rule/component refs, corrupt protobuf columns); output.write() failure; DB connection loss.","commonSituations":"Projects with issues referencing rules or components absent from the dump; corrupt ISSUES blobs (locations, message formattings); DB instability during long exports of large projects.","solutions":["Inspect the wrapped cause: for missing refs ensure all rules/components of the issues are exported (check earlier export steps' logs).","Fix DB connectivity/timeout issues and retry the export task.","Verify ISSUES protobuf columns parse cleanly; repair corrupt rows.","Ensure consistent SonarQube DB schema version (run upgrades)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"long issues = dbClient.issueDao().countByProject(projectUuid); // pre-check accessibility and volume before export","typeGuard":null,"tryCatchPattern":"try {\n  exportIssuesStep.execute(context);\n} catch (IllegalStateException e) {\n  logger.error(\"Issue export failed after {}: {}\", parseCount(e.getMessage()), e.getCause(), e);\n  throw new JobFailure(e.getCause());\n}","preventionTips":["Ensure rules and components referenced by issues exist in the dump","Verify ISSUES protobuf columns are valid after any upgrade","Stabilize DB connectivity before long export tasks","Always inspect e.getCause() for the actionable error"],"tags":["export","issues","database","sonarqube"],"backgroundTag":"database-query-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"}