{"record":{"id":"5733b043546d25db","repo":"apache/beam","slug":"unexpected-protocol-buffers-field-type-type","errorCode":null,"errorMessage":"Unexpected Protocol Buffers field type: ${type}","messagePattern":"Unexpected Protocol Buffers field type: (.+?)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtobufUtil.java","lineNumber":148,"sourceCode":"      case INT64:\n      case SFIXED32:\n      case SFIXED64:\n      case SINT32:\n      case SINT64:\n      case STRING:\n      case UINT32:\n      case UINT64:\n        // Primitive types do not transitively access anything else.\n        break;\n\n      case GROUP:\n      case MESSAGE:\n        // Recursively adds all the fields from this nested Message.\n        recursivelyAddDescriptors(field.getMessageType(), descriptors, registry);\n        break;\n\n      default:\n        throw new UnsupportedOperationException(\n            \"Unexpected Protocol Buffers field type: \" + field.getType());\n    }\n  }\n}\n","sourceCodeStart":130,"sourceCodeEnd":153,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtobufUtil.java#L130-L153","documentation":"recursivelyAddDescriptors walks a proto message's fields to collect all descriptors (and registry entries) needed for dynamic message construction. It handles scalars, enums, and nested MESSAGE types; any other field Type reaching the default branch throws UnsupportedOperationException, since the collector doesn't know how to descend into that field kind.","triggerScenarios":"Building a dynamic proto message/coder for a message type that contains a field kind outside the handled set — most commonly a GROUP field or an unexpected type produced by parsing a FileDescriptorSet with kinds the routine doesn't model.","commonSituations":"Old proto2 definitions using `group` syntax; programmatically constructed descriptors with unusual types; Beam expansion responses carrying descriptors the local collector can't walk.","solutions":["Rewrite the proto2 `group` declaration as an ordinary nested message field.","Check which field type triggers it (from the exception's type text) and replace it with a supported scalar/message/enum type.","Upgrade Beam to a version whose recursivelyAddDescriptors covers the field type, or pre-transform the FileDescriptorSet before registering it."],"exampleFix":"// before (proto2)\nmessage SearchResponse {\n  repeated group Result = 1 { required string url = 2; } // GROUP -> UnsupportedOperationException\n}\n// after\nmessage SearchResponse {\n  message Result { required string url = 2; }\n  repeated Result result = 1;\n}","handlingStrategy":"try-catch","validationCode":"// Java: walk descriptors first and fail fast on unhandled kinds such as GROUP\nstatic boolean hasUnsupportedKind(Descriptors.Descriptor d, Set<String> visited) {\n  if (!visited.add(d.getFullName())) return false;\n  for (Descriptors.FieldDescriptor f : d.getFields()) {\n    if (f.getType() == Descriptors.FieldDescriptor.Type.GROUP) return true;\n    if (f.getType() == Descriptors.FieldDescriptor.Type.MESSAGE && hasUnsupportedKind(f.getMessageType(), visited)) return true;\n  }\n  return false;\n}","typeGuard":null,"tryCatchPattern":"try { registry = ProtobufUtil.registerProtoDescriptors(...); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith(\"Unexpected Protocol Buffers field type:\")) { /* rewrite that field kind in the proto */ } else throw e; }","preventionTips":["Convert proto2 group syntax to nested messages before using protos in Beam.","Lint FileDescriptorSets with protoc/Buf to catch unusual field kinds before registration.","Pin/upgrade Beam versions together with the protobuf-java runtime your protos are compiled with."],"tags":["protobuf","descriptor","java","unsupported-type"],"backgroundTag":"unsupported-operation","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"}