{"record":{"id":"b6e30c15ed7ad1fd","repo":"apache/beam","slug":"decode-not-implemented-s","errorCode":null,"errorMessage":"Decode not implemented: %s.","messagePattern":"Decode not implemented: (.+?)\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/coders/coders.py","lineNumber":148,"sourceCode":"def deserialize_coder(serialized):\n  from apache_beam.internal import pickler\n  return pickler.loads(serialized.split(b'$', 1)[1], use_zlib=True)\n\n\n# pylint: enable=wrong-import-order, wrong-import-position\n\n\nclass Coder(object):\n  \"\"\"Base class for coders.\"\"\"\n  def encode(self, value):\n    # type: (Any) -> bytes\n\n    \"\"\"Encodes the given object into a byte string.\"\"\"\n    raise NotImplementedError('Encode not implemented: %s.' % self)\n\n  def decode(self, encoded):\n    \"\"\"Decodes the given byte string into the corresponding object.\"\"\"\n    raise NotImplementedError('Decode not implemented: %s.' % self)\n\n  def encode_nested(self, value):\n    \"\"\"Uses the underlying implementation to encode in nested format.\"\"\"\n    return self.get_impl().encode_nested(value)\n\n  def decode_nested(self, encoded):\n    \"\"\"Uses the underlying implementation to decode in nested format.\"\"\"\n    return self.get_impl().decode_nested(encoded)\n\n  def is_deterministic(self):\n    # type: () -> bool\n\n    \"\"\"Whether this coder is guaranteed to encode values deterministically.\n\n    A deterministic coder is required for key coders in GroupByKey operations\n    to produce consistent results.\n\n    For example, note that the default coder, the PickleCoder, is not","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/coders/coders.py#L130-L166","documentation":"Coder.decode is abstract in apache_beam; the base class raises NotImplementedError('Decode not implemented: %s.') when a Coder subclass does not override decode. Decoding happens whenever the pipeline materializes elements from encoded bytes (checkpoint marks, side inputs, retries), so this surfaces at read time.","triggerScenarios":"Calling coder.decode(bytes) on a base Coder or subclass that omitted decode; triggered by checkpoint readers, decodeFromBase64, bag page values, or pipeline code that round-trips encoded values.","commonSituations":"Custom coders implemented with only encode; coders for write-only usage later reused for reading; accidental use of base Coder instead of a concrete one.","solutions":["Implement decode(self, encoded) in your Coder subclass","Use ToBytesCoder only for write paths and a real coder where decoding is needed","Round-trip test your coder (beam.WindowValue/beam.Coder test helpers) before running pipelines"],"exampleFix":"// before\nclass MyCoder(Coder):\n    def encode(self, value):\n        return str(value).encode()\n// after\nclass MyCoder(Coder):\n    def encode(self, value):\n        return str(value).encode()\n    def decode(self, encoded):\n        return int(encoded.decode())","handlingStrategy":"type-guard","validationCode":"if type(coder).decode is Coder.decode:\n    raise TypeError('coder does not implement decode')","typeGuard":"def is_decodable(coder):\n    return callable(getattr(coder, 'decode', None)) and type(coder).decode is not Coder.decode","tryCatchPattern":"try:\n    value = coder.decode(blob)\nexcept NotImplementedError as e:\n    log.error('coder %s cannot decode: %s', coder, e)\n    value = None  # or use an alternative reader","preventionTips":["Never use write-only coders on read paths","Unit-test encode->decode round trips","Subclass concrete coders rather than the abstract Coder"],"tags":["python","apache-beam","serialization","abstract-method","decode"],"backgroundTag":"method-not-implemented","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}