Skip to content

Commit 8e7beb6

Browse files
Support unwrapping unknown implementations of proto.Message (#1207)
* Support unwrapping unknown implementations of `proto.Message` Signed-off-by: Sri Krishna <[email protected]> * Add test case Signed-off-by: Sri Krishna <[email protected]> --------- Signed-off-by: Sri Krishna <[email protected]> Co-authored-by: Sri Krishna <[email protected]>
1 parent 8750458 commit 8e7beb6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

common/types/pb/type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ func unwrap(desc description, msg proto.Message) (any, bool, error) {
472472
}
473473
return v.GetValue(), true, nil
474474
}
475-
return msg, false, nil
475+
return unwrapDynamic(desc, msg.ProtoReflect())
476476
}
477477

478478
// unwrapDynamic unwraps a reflected protobuf Message value.

common/types/pb/type_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ func TestTypeDescriptionMaybeUnwrap(t *testing.T) {
430430
in: dpb.New(time.Duration(345)),
431431
out: time.Duration(345),
432432
},
433+
{
434+
in: struct{ proto.Message }{wrapperspb.Int32(1234)},
435+
out: int32(1234),
436+
},
433437
}
434438
for _, tc := range tests {
435439
typeName := string(tc.in.ProtoReflect().Descriptor().FullName())

0 commit comments

Comments
 (0)