Skip to content

Commit

Permalink
Correct generated field mask for google.protobuf.Struct field (#2619)
Browse files Browse the repository at this point in the history
* correct generate field mask for google.protobuf.struct
 field

* added test case for found issue with struct field
  • Loading branch information
marsianin committed Apr 3, 2022
1 parent 384f5e8 commit db5269c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/fieldmask.go
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions runtime/fieldmask_test.go
Expand Up @@ -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{},
Expand Down

0 comments on commit db5269c

Please sign in to comment.