{"record":{"id":"894318e4c6815108","repo":"SonarSource/sonarqube","slug":"can-not-parse-message","errorCode":null,"errorMessage":"Can not parse message","messagePattern":"Can not parse message","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/util/Protobuf2.java","lineNumber":59,"sourceCode":"      throw new IllegalStateException(\"Can not write message \" + msg, e);\n    }\n    return this;\n  }\n\n  public Protobuf2 writeDelimitedTo(Message msg, OutputStream output) {\n    try {\n      msg.writeDelimitedTo(output);\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Can not write message \" + msg, e);\n    }\n    return this;\n  }\n\n  public <M extends Message> M parseFrom(Parser<M> parser, InputStream input) {\n    try {\n      return parser.parseFrom(input);\n    } catch (InvalidProtocolBufferException e) {\n      throw new IllegalStateException(\"Can not parse message\", e);\n    }\n  }\n\n  @CheckForNull\n  public <M extends Message> M parseDelimitedFrom(Parser<M> parser, InputStream input) {\n    try {\n      return parser.parseDelimitedFrom(input);\n    } catch (InvalidProtocolBufferException e) {\n      throw new IllegalStateException(\"Can not parse message\", e);\n    }\n  }\n}\n","sourceCodeStart":41,"sourceCodeEnd":72,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/util/Protobuf2.java#L41-L72","documentation":"Protobuf2.parseFrom wraps InvalidProtocolBufferException into an IllegalStateException with message \"Can not parse message\". It means the bytes in the input stream are not a valid protobuf message for the expected parser/type.","triggerScenarios":"Calling parseFrom(parser, input) when the stream contains truncated, corrupted, empty, or wrong-type protobuf bytes.","commonSituations":"Version mismatch between writer and reader of the data (schema changed); corrupted files on disk; reading a non-protobuf file; truncated transfer.","solutions":["Verify the data was written by a compatible protobuf schema version","Check the stream is not truncated or empty before parsing","Regenerate or re-fetch the corrupted data","Confirm the parser matches the message type that was serialized"],"exampleFix":"// before\nMyMessage msg = protobuf2.parseFrom(MyMessage.parser(), input);\n// after\nif (input.available() == 0) {\n  throw new IllegalStateException(\"Empty input, nothing to parse\");\n}\nMyMessage msg = protobuf2.parseFrom(MyMessage.parser(), input);","handlingStrategy":"try-catch","validationCode":"byte[] data = input.readAllBytes();\nif (data.length == 0) {\n  throw new IllegalArgumentException(\"No data to parse\");\n}\ninput = new ByteArrayInputStream(data);","typeGuard":null,"tryCatchPattern":"try {\n  MyMessage msg = protobuf2.parseFrom(MyMessage.parser(), input);\n} catch (IllegalStateException e) {\n  LOGGER.warn(\"Corrupt or incompatible protobuf data\", e.getCause());\n  // discard record or fail with clear user-facing message\n}","preventionTips":["Pin compatible protobuf schema versions between writer and reader","Validate checksums on stored protobuf files","Never parse streams of unknown/non-protobuf content","Handle empty inputs before parsing"],"tags":["protobuf","deserialization","corrupt-data"],"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"}