-
Notifications
You must be signed in to change notification settings - Fork 824
Closed
Description
Describe the bug
A struct generated from a .proto schema with a timestamp is written to mongodb but panics when reading it.
To Reproduce
$ go version go version go1.14.3 linux/amd64
Using a protobuf specification like
import "google/protobuf/timestamp.proto";
message Test{
...
google.protobuf.Timestamp start_date = 4;
}
Will result in a struct like
type Test struct{
...
StartTime *timestamp.Timestamp `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
}Writing this to a mongodb instance will work and checking via mongo shell shows binary data:
{
"_id" : "3d964883c5e60d36",
"DocstoreRevision" : "2f1954b9-f038-440c-b0e0-c0ed88f2d04a",
...
"StartDate" : BinData(0,"CIDCr/AF"),
}
Which causes a panic when read via the go cloud cdk:
panic: reflect.Set: value of type []uint8 is not assignable to type *timestamppb.Timestamp
goroutine 28 [running]:
reflect.Value.assignTo(0xca0040, 0xc0000a8900, 0x97, 0xe166df, 0xb, 0xd81da0, 0x0, 0xc0000a8900, 0x0, 0x0)
/snap/go/5759/src/reflect/value.go:2403 +0x426
reflect.Value.Set(0xd81da0, 0xc0000ae670, 0x196, 0xca0040, 0xc0000a8900, 0x97)
/snap/go/5759/src/reflect/value.go:1532 +0xbd
gocloud.dev/docstore/driver.decode(0xd81da0, 0xc0000ae670, 0x196, 0x1013c00, 0xc0000a88e0, 0x2, 0xd81da0)
/home/carsten/go/pkg/mod/gocloud.dev@v0.19.0/docstore/driver/codec.go:391 +0x193
gocloud.dev/docstore/driver.decodeStruct.func1(0xc0000aa970, 0x9, 0x1013c00, 0xc0000a88e0, 0x40dd01, 0xc000144d40)
/home/carsten/go/pkg/mod/gocloud.dev@v0.19.0/docstore/driver/codec.go:679 +0x15b
gocloud.dev/docstore/mongodocstore.decoder.DecodeMap(0xcfdd00, 0xc000462630, 0x0, 0xc000144d40)
/home/carsten/go/pkg/mod/gocloud.dev/docstore/mongodocstore@v0.19.0/codec.go:242 +0x12d
gocloud.dev/docstore/driver.decodeStruct(0xd6aae0, 0xc0000ae660, 0x199, 0x1013c00, 0xc0000a88c0, 0xc0005b1d18, 0xc0000a88c0)
/home/carsten/go/pkg/mod/gocloud.dev@v0.19.0/docstore/driver/codec.go:658 +0x171
gocloud.dev/docstore/driver.Document.Decode(0xdbd640, 0xc0000ae660, 0x0, 0xd6aae0, 0xc0000ae660, 0x199, 0xc000121500, 0xa, 0x10, 0x1013c00, ...)
/home/carsten/go/pkg/mod/gocloud.dev@v0.19.0/docstore/driver/document.go:184 +0x142
gocloud.dev/docstore/mongodocstore.decodeDoc(0xc000462630, 0xdbd640, 0xc0000ae660, 0x0, 0xd6aae0, 0xc0000ae660, 0x199, 0xc000121500, 0xa, 0x10, ...)
/home/carsten/go/pkg/mod/gocloud.dev/docstore/mongodocstore@v0.19.0/codec.go:125 +0x115
gocloud.dev/docstore/mongodocstore.(*docIterator).Next(0xc0004623f0, 0x1005ca0, 0xc000481080, 0xdbd640, 0xc0000ae660, 0x0, 0xd6aae0, 0xc0000ae660, 0x199, 0xc000121500, ...)
/home/carsten/go/pkg/mod/gocloud.dev/docstore/mongodocstore@v0.19.0/query.go:127 +0xe6
gocloud.dev/docstore.(*DocumentIterator).Next(0xc000462420, 0x1005ca0, 0xc000481080, 0xdbd640, 0xc0000ae660, 0xc0003426b0, 0x1)
/home/carsten/go/pkg/mod/gocloud.dev@v0.19.0/docstore/query.go:234 +0x204
main.(*ServerJob).GetJobs(0xc00048a400, 0x1005ca0, 0xc000481080, 0xc0002b6508, 0x0, 0x0, 0x0)
...
Expected behavior
Using the in memory docstore i can see the expected behavior of the struct being filled with data.
input: {StartDate:seconds:1589872418 nanos:319671987 ...
output: {StartDate:seconds:1589872418 nanos:319671987 ...
Version
gocloud.dev v0.19.0
gocloud.dev/docstore/mongodocstore v0.19.0
Additional context
Metadata
Metadata
Assignees
Labels
No labels