golang / protobuf

Go support for Google's protocol buffers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proto.Clone() panic: cannot return value obtained from unexported field or method

HeyiSun opened this issue · comments

What version of protobuf and what language are you using?
Version: v1.5.3

What did you do?
I wrote a grpc server. In the server handler, I try to clone the request message after receiving it from the stream.
My proto file is almost same with https://github.com/googleapis/googleapis/blob/master/google/devtools/build/v1/publish_build_event.proto, with some modification on include path.

func (s *BesServer) PublishBuildToolEventStream(stream pepb.PublishBuildEvent_PublishBuildToolEventStreamServer) error {
    in, err := stream.Recv()
    if err == nil {
        _ = proto.Clone(in).(*pepb.PublishBuildToolEventStreamRequest)
    }
    return nil
}

What did you expect to see?
Deep copy the message

What did you see instead?
Panic:

panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

goroutine 358 [running]:
reflect.valueInterface({0x1634cc0?, 0xc001a65b60?, 0xd0?}, 0x0?)
        GOROOT/src/reflect/value.go:1489 +0xd8
reflect.Value.Interface(...)
        GOROOT/src/reflect/value.go:1478
github.com/gogo/protobuf/proto.mergeStruct({0x1706e00?, 0xc0022bc180?, 0x10?}, {0x1706e00?, 0xc001a65b60?, 0x182b1a0?})
        external/com_github_gogo_protobuf/proto/clone.go:111 +0x285
github.com/gogo/protobuf/proto.mergeAny({0x1706e00?, 0xc0022bc180?, 0x0?}, {0x1706e00?, 0xc001a65b60?, 0x1706e00?}, 0x0, 0xc001bea900)
        external/com_github_gogo_protobuf/proto/clone.go:236 +0xbe5
github.com/gogo/protobuf/proto.mergeStruct({0x182b1a0?, 0xc0022bc180?, 0x2710?}, {0x182b1a0?, 0xc001a65b60?, 0x7f6860619588?})
        external/com_github_gogo_protobuf/proto/clone.go:108 +0x256
github.com/gogo/protobuf/proto.mergeAny({0x182b1a0?, 0xc0022bc180?, 0x1652d3a?}, {0x182b1a0?, 0xc001a65b60?, 0x182b1a0?}, 0x0, 0xc0002d4c00)
        external/com_github_gogo_protobuf/proto/clone.go:236 +0xbe5
github.com/gogo/protobuf/proto.mergeStruct({0x1867380?, 0xc0022bc180?, 0xc0022bc180?}, {0x1867380?, 0xc001a65b60?, 0x60?})
        external/com_github_gogo_protobuf/proto/clone.go:108 +0x256
github.com/gogo/protobuf/proto.Merge({0x1c69930?, 0xc0022bc180}, {0x1c69930?, 0xc001a65b60})
        external/com_github_gogo_protobuf/proto/clone.go:98 +0x513
github.com/gogo/protobuf/proto.Clone({0x1c69930?, 0xc001a65b60?})
        external/com_github_gogo_protobuf/proto/clone.go:52 +0x1a5
code.byted.org/inf/buildboard/buildboard/build_event_server.(*BesServer).PublishBuildToolEventStream.func1()
        buildboard/build_event_server/bes_server.go:96 +0xca
created by code.byted.org/inf/buildboard/buildboard/build_event_server.(*BesServer).PublishBuildToolEventStream
        buildboard/build_event_server/bes_server.go:93 +0x4ea

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment?

Sorry, I accidentally used deprecated repo: https://github.com/gogo/protobuf