{"record":{"id":"8ae8fa66505323cf","repo":"apache/beam","slug":"invalid-encoded-solrdocument-length-len","errorCode":null,"errorMessage":"Invalid encoded SolrDocument length: ${len}","messagePattern":"Invalid encoded SolrDocument length: (.+?)","errorType":"exception","errorClass":"CoderException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/solr/src/main/java/org/apache/beam/sdk/io/solr/JavaBinCodecCoder.java","lineNumber":74,"sourceCode":"      throw new CoderException(\"cannot encode a null SolrDocument\");\n    }\n\n    ByteArrayOutputStream baos = new ByteArrayOutputStream();\n    JavaBinCodec codec = new JavaBinCodec();\n    codec.marshal(value, baos);\n\n    byte[] bytes = baos.toByteArray();\n    VarInt.encode(bytes.length, outStream);\n    outStream.write(bytes);\n  }\n\n  @Override\n  public T decode(InputStream inStream) throws IOException {\n    DataInputStream in = new DataInputStream(inStream);\n\n    int len = VarInt.decodeInt(in);\n    if (len < 0) {\n      throw new CoderException(\"Invalid encoded SolrDocument length: \" + len);\n    }\n\n    JavaBinCodec codec = new JavaBinCodec();\n    return (T) codec.unmarshal(new BoundedInputStream(in, len));\n  }\n\n  @Override\n  public TypeDescriptor<T> getEncodedTypeDescriptor() {\n    return TypeDescriptor.of(clazz);\n  }\n\n  @AutoService(CoderProviderRegistrar.class)\n  public static class Provider implements CoderProviderRegistrar {\n    @Override\n    public List<CoderProvider> getCoderProviders() {\n      return Arrays.asList(\n          CoderProviders.forCoder(\n              TypeDescriptor.of(SolrDocument.class), JavaBinCodecCoder.of(SolrDocument.class)),","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/solr/src/main/java/org/apache/beam/sdk/io/solr/JavaBinCodecCoder.java#L56-L92","documentation":"JavaBinCodecCoder prefixes each encoded SolrDocument with a VarInt length. During decode, a negative length means the encoded bytes are corrupt or were produced by an incompatible coder, so decoding cannot proceed and a CoderException is thrown.","triggerScenarios":"Decoding a byte stream whose VarInt header is negative — typically caused by corrupt/missing bytes, a coder version mismatch between writer and reader, or reading a stream offset misaligned with the length-prefixed framing.","commonSituations":"Stale checkpoints or state files written by a different Beam/SolrIO version; data corruption in transit; mixing JavaBinCodecCoder output with another coder's bytes.","solutions":["Regenerate the corrupted state/checkpoint data or rerun the pipeline from the source","Ensure the same Beam SDK and SolrIO version are used to encode and decode (avoid mixing versions in a cluster)","Verify the coder registered for the PCollection is actually JavaBinCodecCoder and not wrapped/mismatched"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"int len = VarInt.decodeInt(in);\nif (len < 0) {\n  throw new CoderException(\"Invalid encoded SolrDocument length: \" + len);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return coder.decode(in);\n} catch (CoderException e) {\n  LOG.error(\"Corrupt or incompatible encoded SolrDocument bytes\", e);\n  throw e;\n}","preventionTips":["Use identical SDK/SolrIO versions for writers and readers","Avoid manually editing or truncating coder-produced streams","Regenerate checkpoints/state after upgrading coders","Verify coder registration on the PCollection"],"tags":["java","beam","solr","coder","corrupt-data"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}