{"record":{"id":"5505533d8ea82a1a","repo":"apache/beam","slug":"could-not-transport-value-error-s","errorCode":null,"errorMessage":"Could not transport value. Error: %s","messagePattern":"Could not transport value\\. Error: (.+?)","errorType":"exception","errorClass":"CoderException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/thrift/src/main/java/org/apache/beam/sdk/io/thrift/ThriftCoder.java","lineNumber":79,"sourceCode":"    return new ThriftCoder<>(clazz, protocolFactory);\n  }\n\n  /**\n   * Encodes the given value of type {@code T} onto the given output stream using provided {@link\n   * ThriftCoder#protocolFactory}.\n   *\n   * @param value {@link org.apache.thrift.TBase} to encode.\n   * @param outStream stream to output encoded value to.\n   * @throws IOException if writing to the {@code OutputStream} fails for some reason\n   */\n  @Override\n  public void encode(T value, OutputStream outStream) throws CoderException, IOException {\n    try {\n      TProtocol protocol = protocolFactory.getProtocol(new TIOStreamTransport(outStream));\n      TBase<?, ?> tBase = (TBase<?, ?>) value;\n      tBase.write(protocol);\n    } catch (TTransportException tte) {\n      throw new CoderException(\"Could not transport value. Error: \" + tte.getMessage());\n    } catch (Exception te) {\n      throw new CoderException(\"Could not write value. Error: \" + te.getMessage());\n    }\n  }\n\n  /**\n   * Decodes a value of type {@code T} from the given input stream using provided {@link\n   * ThriftCoder#protocolFactory}. Returns the decoded value.\n   *\n   * @param inStream stream of input values to be decoded\n   * @throws IOException if reading from the {@code InputStream} fails for some reason\n   * @throws CoderException if the value could not be decoded for some reason\n   * @return {@link TBase} decoded object\n   */\n  @Override\n  public T decode(InputStream inStream) throws CoderException, IOException {\n    try {\n      TProtocol protocol = protocolFactory.getProtocol(new TIOStreamTransport(inStream));","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/thrift/src/main/java/org/apache/beam/sdk/io/thrift/ThriftCoder.java#L61-L97","documentation":"ThriftCoder serializes TBase Thrift objects to a stream via a Thrift protocol/transport. When the underlying TTransportException occurs during writing (broken transport, closed stream, protocol errors), encode wraps it in a CoderException with the transport message. It signals the Thrift serialization itself failed at the transport layer, distinct from the generic write failure branch.","triggerScenarios":"Calling Beam's ThriftIO or using ThriftCoder directly to encode a TBase object when the TIOStreamTransport's underlying OutputStream throws, the protocol write exceeds transport limits, or serialization hits a TTransportException (e.g., end of stream, transport closed).","commonSituations":"Encoding during a sink write where the output stream was closed early (e.g., worker shutdown, channel break); encoding very large Thrift structs; malformed generated Thrift classes (wrong protocol factory — e.g., binary protocol vs compact) causing transport-level failures.","solutions":["Inspect the CoderException message (the original TTransportException text) and the underlying cause to identify the transport failure.","Ensure the OutputStream passed to encode is open and writable for the duration of serialization.","Match the protocolFactory to how the data will be read (TTupleProtocol/TBinaryProtocol/TCompactProtocol consistency between encode and decode).","Retry the write; if transient stream breakage in a pipeline, rely on Beam's retry semantics rather than swallowing."],"exampleFix":"// before\nCoder<MyEvent> coder = ThriftCoder.of(MyEvent.class); // mismatched protocol vs reader\n// after — ensure same protocol factory used by both encoder and decoder\nCoder<MyEvent> coder = ThriftCoder.of(\n    new TSerializer(new TCompactProtocol.Factory()),\n    new TDeserializer(new TCompactProtocol.Factory()),\n    MyEvent.class);","handlingStrategy":"try-catch","validationCode":"// Java — validate the value is a TBase before encoding\nif (!(value instanceof TBase)) {\n  throw new IllegalArgumentException(\"ThriftCoder only encodes TBase instances\");\n}","typeGuard":"boolean encodable(Object v) { return v instanceof TBase; }","tryCatchPattern":"try {\n  coder.encode(event, outStream);\n} catch (CoderException e) {\n  // transport-level Thrift failure: inspect message/cause, check stream state and protocol factory match\n  LOG.error(\"Thrift transport failure while encoding: {}\", e.getMessage());\n}","preventionTips":["Use the same protocol factory for ThriftCoder encode and decode.","Ensure output streams stay open through the whole encode call.","Prefer compact/binary protocols consistently and test round-trip encode/decode in unit tests."],"tags":["apache-beam","java","thrift","coder","serialization"],"backgroundTag":"json-serialization-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}