From db5269c3cc7054724a4f339880efcf184a37c915 Mon Sep 17 00:00:00 2001 From: Rinat Takhautdinov Date: Mon, 4 Apr 2022 01:04:51 +0700 Subject: [PATCH] Correct generated field mask for google.protobuf.Struct field (#2619) * correct generate field mask for google.protobuf.struct field * added test case for found issue with struct field --- runtime/fieldmask.go | 2 +- runtime/fieldmask_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/fieldmask.go b/runtime/fieldmask.go index 0138ed2f769..82ab3d277b2 100644 --- a/runtime/fieldmask.go +++ b/runtime/fieldmask.go @@ -53,7 +53,7 @@ func FieldMaskFromRequestBody(r io.Reader, msg proto.Message) (*field_mask.Field } if isDynamicProtoMessage(fd.Message()) { - for _, p := range buildPathsBlindly(k, v) { + for _, p := range buildPathsBlindly(string(fd.FullName().Name()), v) { newPath := p if item.path != "" { newPath = item.path + "." + newPath diff --git a/runtime/fieldmask_test.go b/runtime/fieldmask_test.go index e458211a48e..fe3f0957968 100644 --- a/runtime/fieldmask_test.go +++ b/runtime/fieldmask_test.go @@ -60,6 +60,12 @@ func TestFieldMaskFromRequestBody(t *testing.T) { input: `{"struct_field": {"name":{"first": "bob"}, "amount": 2}}`, expected: newFieldMask("struct_field.name.first", "struct_field.amount"), }, + { + name: "NonStandardMessageWithJSONNamesForStruct", + msg: &examplepb.NonStandardMessage{}, + input: `{"lineNum": 123, "structField": {"name":"bob"}}`, + expected: newFieldMask("line_num", "struct_field.name"), + }, { name: "value", msg: &examplepb.NonStandardMessage{},