{"record":{"id":"86629a266205d40a","repo":"apache/beam","slug":"unknown-proto-implementation-api-implementation-type","errorCode":null,"errorMessage":"Unknown proto implementation: {api_implementation.Type()}","messagePattern":"Unknown proto implementation: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"sdks/python/gen_protos.py","lineNumber":144,"sourceCode":"    from google.protobuf.internal import containers\n    repeated_types = (\n        list,\n        containers.RepeatedScalarFieldContainer,\n        containers.RepeatedCompositeFieldContainer)\n  elif api_implementation.Type() == 'upb':\n    from google._upb import _message\n    repeated_types = (\n        list,\n        _message.RepeatedScalarContainer,\n        _message.RepeatedCompositeContainer)\n  elif api_implementation.Type() == 'cpp':\n    from google.protobuf.pyext import _message\n    repeated_types = (\n        list,\n        _message.RepeatedScalarContainer,\n        _message.RepeatedCompositeContainer)\n  else:\n    raise TypeError(\n        \"Unknown proto implementation: \" + api_implementation.Type())\n\n  class Context(object):\n    INDENT = '  '\n    CAP_SPLIT = re.compile('([A-Z][^A-Z]*|^[a-z]+)')\n\n    def __init__(self, indent=0):\n      self.lines = []\n      self.imports = set()\n      self.empty_types = set()\n      self._indent = indent\n\n    @contextlib.contextmanager\n    def indent(self):\n      self._indent += 1\n      yield\n      self._indent -= 1\n","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/gen_protos.py#L126-L162","documentation":"gen_protos.py selects the protobuf runtime implementation (upb, cpp, or python) to pick the right repeated-field container types. If api_implementation.Type() returns an unrecognized value, generation cannot proceed and raises TypeError.","triggerScenarios":"Running the proto generation script with a protobuf runtime whose api_implementation.Type() is not one of the handled values (e.g. a very new or unusual protobuf build).","commonSituations":"Installing an experimental or future protobuf version with a new implementation mode; running in an environment with a custom protobuf build.","solutions":["Pin protobuf to a supported version (e.g. pip install 'protobuf<5' or a version known to work with Beam).","Force the pure-python implementation via PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python.","Update gen_protos.py to handle the new implementation type if supporting a newer protobuf."],"exampleFix":"// before (shell)\npip install -U protobuf\n// after\npip install 'protobuf==4.25.3'","handlingStrategy":"validation","validationCode":"from google.protobuf import internal\nimpl = internal.api_implementation.Type()\nassert impl in ('upb', 'cpp', 'python'), f\"unsupported protobuf impl: {impl}\"","typeGuard":"def has_supported_protobuf_impl():\n    from google.protobuf import internal\n    return internal.api_implementation.Type() in ('upb', 'cpp', 'python')","tryCatchPattern":"try:\n    generate_proto_files()\nexcept TypeError as e:\n    if 'Unknown proto implementation' in str(e):\n        os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'\n        # re-exec or reinstall a supported protobuf","preventionTips":["Pin protobuf to a Beam-supported version in dev requirements.","Check impl type before running generation in CI.","Avoid globally upgrading protobuf while building Beam."],"tags":["protobuf","code-generation","environment","apache-beam"],"backgroundTag":"unsupported-platform","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"}