{"record":{"id":"9597f2651b1dc103","repo":"apache/beam","slug":"could-not-find-enum-descriptor-full-name","errorCode":null,"errorMessage":"Could not find enum descriptor: {full_name}","messagePattern":"Could not find enum descriptor: (.+?)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/internal/cloudpickle_pickler.py","lineNumber":138,"sourceCode":"def _reconstruct_enum_descriptor(full_name):\n  for _, module in list(sys.modules.items()):\n    if not hasattr(module, 'DESCRIPTOR'):\n      continue\n\n    if hasattr(module.DESCRIPTOR, 'enum_types_by_name'):\n      for (_, enum_desc) in module.DESCRIPTOR.enum_types_by_name.items():\n        if enum_desc.full_name == full_name:\n          return enum_desc\n\n    for _, attr_value in vars(module).items():\n      if not hasattr(attr_value, 'DESCRIPTOR'):\n        continue\n\n      if hasattr(attr_value.DESCRIPTOR, 'enum_types_by_name'):\n        for (_, enum_desc) in attr_value.DESCRIPTOR.enum_types_by_name.items():\n          if enum_desc.full_name == full_name:\n            return enum_desc\n  raise ImportError(f'Could not find enum descriptor: {full_name}')\n\n\ndef _pickle_enum_descriptor(obj):\n  full_name = obj.full_name\n  return _reconstruct_enum_descriptor, (full_name, )\n\n\ndef dumps(\n    o,\n    enable_trace=True,\n    use_zlib=False,\n    enable_best_effort_determinism=False,\n    enable_stable_code_identifier_pickling=False,\n    config: cloudpickle.CloudPickleConfig = DEFAULT_CONFIG) -> bytes:\n  \"\"\"For internal use only; no backwards-compatibility guarantees.\"\"\"\n  s = _dumps(\n      o,\n      enable_best_effort_determinism,","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/internal/cloudpickle_pickler.py#L120-L156","documentation":"_reconstruct_enum_descriptor() scans loaded protobuf descriptor pools for an enum descriptor matching the given full_name and raises ImportError when none matches. This happens during unpickling of protobuf EnumDescriptor objects that Beam's pickler serialized by name.","triggerScenarios":"Unpickling a session/pipeline whose pickled enum descriptor's full_name no longer exists in the current .proto definitions — the proto was renamed, removed, or the proto file was never imported so its descriptors are not in the pool.","commonSituations":"Proto schema changed between save and load; worker image lacks the proto module containing the enum; proto package name changed; deserializing old saved sessions (load_session) against newer code.","solutions":["Import the Python module generated from the .proto file before loading, so its descriptors register in the pool.","Restore/revert the enum's original full_name, or re-save the session with current protos.","Ensure the worker environment includes the same proto definitions version used when pickling.","Search the descriptor pool for the enum and update references if it was renamed."],"exampleFix":"// before\nwith beam.Pipeline() as p:  # enum proto never imported on worker\n    ...\n// after\nimport myprotos_pb2  # registers enum descriptors\nload_session('session.pkl')","handlingStrategy":"try-catch","validationCode":"from google.protobuf import descriptor_pool\nassert full_name in descriptor_pool.Default().EnumDescriptors() or True  # probe pool before load","typeGuard":"def enum_in_pool(full_name: str) -> bool:\n    try:\n        from google.protobuf import descriptor_pool\n        descriptor_pool.Default().FindEnumTypeByName(full_name)\n        return True\n    except KeyError:\n        return False","tryCatchPattern":"try:\n    load_session(path)\nexcept ImportError as e:\n    if 'Could not find enum descriptor' in str(e):\n        import suspect_protos_pb2  # register missing descriptors and retry\n        load_session(path)\n    else:\n        raise","preventionTips":["Import all generated proto modules before unpickling.","Keep proto schemas in sync between save and load environments.","Use identical Beam/proto versions in workers."],"tags":["python","apache-beam","protobuf","deserialization"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}