Fix oneof field validation

This commit is contained in:
Ravi Khadiwala authored and ravi-signal committed 2026-03-06 14:49:26 -06:00
1 parent f5f217f3de
commit a90fa5db02
5 files changed
+43 -9

No files matched your search

@@ -94,6 +94,12 @@ public class ValidatingInterceptor implements ServerInterceptor {
final Descriptors.FieldDescriptor extensionFieldDescriptor = entry.getKey();
final String extensionName = extensionFieldDescriptor.getFullName();
// If this is a oneof, but this field isn't set, we shouldn't validate it. We assume if you have a validator
// that requires presence, you don't actually want presence enforcement on a oneof case.
if (fd.getRealContainingOneof() != null && !msg.hasField(fd)) {
continue;
}
// first validate the field
final FieldValidator validator = fieldValidators.get(extensionName);
// not all extensions are validators, so `validator` value here could legitimately be `null`