I have a protobuf message with a repeated field:
message TestRepeatedMask {
repeated Inner inner_message = 1;
message Inner {
optional string first = 1;
optional string second = 2;
}
}
I know the docs for fieldmasks state that you can't select one field from within each member of the list of elements, but OTOH there's this documentation for wildcards that says you can use ".*."
within the fieldmask path to do exactly that.
My Java example:
public static TestRepeatedMask readMinimal(TestRepeatedMask route) {
FieldMask.Builder maskBuilder = FieldMask.newBuilder();
FieldMask mask = maskBuilder.addPaths("inner_message.*.first").build();
TestRepeatedMask.Builder result = TestRepeatedMask.newBuilder();
FieldMaskUtil.merge(mask, route, result);
return result.build();
}
@Test
public void readRespo() {
TestRepeatedMask o =
SelectedRouteMasker.readMinimal(
TestRepeatedMask.newBuilder()
.addInnerMessage(Inner.newBuilder().setFirst("first").setSecond("second"))
.build());
System.out.println(o);
}
I'm expecting to get this obect without the "second" field:
TestRepeatedMask { inner { first: "first" } }
I'm running the test and getting:
Oct 15, 2025 9:06:59 AM com.google.protobuf.util.FieldMaskTree merge
WARNING: Field "TestRepeatedMask.inner_message" is not a singular message field and cannot have sub-fields.
Is what I'm trying to do not supported? Am I misreading the wildcard docs?