{"record":{"id":"348f38ce404ca4b3","repo":"apache/beam","slug":"failed-to-get-field-from-proto-field-s","errorCode":null,"errorMessage":"Failed to get field from proto. field: %s","messagePattern":"Failed to get field from proto\\. field: (.+?)","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoBeamConverter.java","lineNumber":412,"sourceCode":"        Descriptors.Descriptor descriptor = message.getDescriptorForType();\n        Descriptors.FieldDescriptor fieldDescriptor =\n            Preconditions.checkNotNull(descriptor.findFieldByName(field.getName()));\n\n        @Nullable Object protoValue;\n        if (field.getType().getNullable()\n            && ProtoSchemaTranslator.isNullable(fieldDescriptor)\n            && !message.hasField(fieldDescriptor)) {\n          // Set null field value only if the Beam field type is nullable and the proto value is\n          // null,\n          protoValue = null;\n        } else {\n          // can be a default value. e.g., an optional field.\n          protoValue = message.getField(fieldDescriptor);\n        }\n\n        return protoValue != null ? converter.convert((@NonNull ProtoT) protoValue) : null;\n      } catch (RuntimeException e) {\n        throw new RuntimeException(\n            String.format(\"Failed to get field from proto. field: %s\", field.getName()), e);\n      }\n    }\n  }\n\n  static class FromProtoOneOfGetter implements FromProtoGetter<OneOfType.@Nullable Value> {\n    private final Schema.Field field;\n    private final OneOfType oneOfType;\n    private final Map<String, ProtoToBeamConverter<Object, Object>> converter;\n\n    FromProtoOneOfGetter(Schema.Field field) {\n      this.field = field;\n      this.oneOfType = Preconditions.checkNotNull(field.getType().getLogicalType(OneOfType.class));\n      this.converter = createConverters(oneOfType.getOneOfSchema());\n    }\n\n    private static Map<String, ProtoToBeamConverter<Object, Object>> createConverters(\n        Schema schema) {","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoBeamConverter.java#L394-L430","documentation":"FromProtoGetter.getFromProto reads a field value off a proto Message and converts it to a Beam value. Any RuntimeException raised while reading/converting the field is wrapped in a RuntimeException identifying the schema field name, so the original cause (type mismatch, null handling, converter failure) is preserved as the cause chain.","triggerScenarios":"Calling getFromProto during proto-to-Beam Row conversion when message.getField(fieldDescriptor) or the field's converter throws (e.g. field descriptor not found on the message, conversion type error).","commonSituations":"Schema/proto descriptor drift (message class changed after schema was built); passing a Message instance that doesn't match the descriptor; a custom converter for the field failing.","solutions":["Read the cause of the wrapped RuntimeException to find the actual failure","Verify the proto Message class and descriptor match the schema the converter was built from","Rebuild the schema/converter after changing the proto definition (stale descriptors are common)","Log field.getName() and check the offending field's type/optional-ness"],"exampleFix":"// before\nRow row = ProtoUtils.rowFromMessage(msg); // throws 'Failed to get field from proto. field: foo'\n// after\ntry { Row row = ProtoUtils.rowFromMessage(msg); } catch (RuntimeException e) { LOG.error(\"field {} failed: \", e.getCause()); }","handlingStrategy":"try-catch","validationCode":"// ensure message descriptor matches the one used to build the schema\nif (!message.getDescriptorForType().getFullName().equals(expectedDescriptor.getFullName())) throw new IllegalStateException(\"descriptor mismatch\");","typeGuard":null,"tryCatchPattern":"try { Row row = converter.apply(message); } catch (RuntimeException e) { LOG.error(\"proto->Beam failed on field {}, cause: {}\", e.getMessage(), e.getCause()); throw e; }","preventionTips":["Regenerate schemas whenever protos change","Log e.getCause() — the wrapper hides the real error","Use a single FileDescriptor source for both schema and runtime messages"],"tags":["protobuf","beam","field-conversion","exception-wrap"],"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-20T03:17:13.778Z"}