{"record":{"id":"66ab9b224147aacd","repo":"SonarSource/sonarqube","slug":"fail-to-read-locations-from-db-for-issue-s","errorCode":null,"errorMessage":"Fail to read locations from DB for issue %s","messagePattern":"Fail to read locations from DB for issue (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java","lineNumber":162,"sourceCode":"      .forEach(builder::addImpacts);\n  }\n\n  private String registerRule(IssueDto issueDto) {\n    String ruleUuid = issueDto.getRuleUuid();\n    RuleKey ruleKey = issueDto.getRuleKey();\n    return ruleRegistrar.register(ruleUuid, ruleKey).ref();\n  }\n\n  private static void setLocations(ProjectDump.Issue.Builder builder, IssueDto issueDto) {\n    try {\n      byte[] bytes = issueDto.getLocations();\n      if (bytes != null) {\n        // fail fast, ensure we can read data from DB\n        DbIssues.Locations.parseFrom(bytes);\n        builder.setLocations(ByteString.copyFrom(bytes));\n      }\n    } catch (InvalidProtocolBufferException e) {\n      throw new IllegalStateException(format(\"Fail to read locations from DB for issue %s\", issueDto.getKee()), e);\n    }\n  }\n\n  private static void setMessageFormattings(ProjectDump.Issue.Builder builder, IssueDto issueDto) {\n    try {\n      byte[] bytes = issueDto.getMessageFormattings();\n      if (bytes != null) {\n        // fail fast, ensure we can read data from DB\n        DbIssues.MessageFormattings messageFormattings = DbIssues.MessageFormattings.parseFrom(bytes);\n        if (messageFormattings != null) {\n          builder.addAllMessageFormattings(dbToDumpMessageFormatting(messageFormattings.getMessageFormattingList()));\n        }\n      }\n    } catch (InvalidProtocolBufferException e) {\n      throw new IllegalStateException(format(\"Fail to read message formattings from DB for issue %s\", issueDto.getKee()), e);\n    }\n  }\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java#L144-L180","documentation":"setLocations() deliberately parses the raw LOCATIONS protobuf bytes from the ISSUES row before copying them into the dump, to fail fast on corrupt data. If DbIssues.Locations.parseFrom throws InvalidProtocolBufferException, the error is wrapped in an IllegalStateException naming the issue key.","triggerScenarios":"ISSUES.LOCATIONS column contains bytes that are not a valid DbIssues.Locations protobuf — e.g. truncated row, manual DB edits, data written by an incompatible SonarQube version, or encoding corruption.","commonSituations":"Partial/failed SonarQube upgrades; restoring a DB backup inconsistent with the schema; storage-level corruption; cross-version data migrations.","solutions":["Identify the issue by its key (in the message) and inspect its LOCATIONS blob; delete or repair the row (e.g. re-run analysis to rewrite issue data).","Restore the affected rows from a consistent DB backup if corruption is widespread.","Verify the SonarQube version that wrote the data matches the one exporting it; complete pending migrations.","Check storage integrity if many rows fail protobuf parsing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"byte[] bytes = issueDto.getLocations();\nif (bytes != null) {\n  try { DbIssues.Locations.parseFrom(bytes); } catch (InvalidProtocolBufferException e) { flagIssueAsCorrupt(issueDto.getKee()); }\n}","typeGuard":"boolean hasValidLocations(IssueDto dto) {\n  byte[] b = dto.getLocations();\n  if (b == null) return true;\n  try { DbIssues.Locations.parseFrom(b); return true; }\n  catch (InvalidProtocolBufferException e) { return false; }\n}","tryCatchPattern":"try {\n  exportIssuesStep.execute(context);\n} catch (IllegalStateException e) {\n  if (e.getCause() instanceof InvalidProtocolBufferException) {\n    logger.error(\"Corrupt locations blob; skip or repair issue data\");\n  }\n}","preventionTips":["Never hand-edit protobuf columns in the DB","Keep SonarQube versions consistent between write and read sides","Restore only consistent, complete DB backups","Re-run analysis to regenerate corrupted issue payloads"],"tags":["protobuf","corruption","issues","database","sonarqube"],"backgroundTag":"protobuf-unmarshal-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"}