When trying to return protobuf structure from activity sdk-go returns an error:
payload item 0: unable to decode: json: cannot unmarshal object into Go struct field Disk.Source of type compute.isDisk_Source (type: wrapError, retryable: true)
Yes, the Source field is a field of the protbuf structure Disk.
type Disk_SourceImageId struct {
// ID of the image that was used for disk creation.
SourceImageId string `protobuf:"bytes,12,opt,name=source_image_id,json=sourceImageId,proto3,oneof"`
}
type Disk_SourceSnapshotId struct {
// ID of the snapshot that was used for disk creation.
SourceSnapshotId string `protobuf:"bytes,13,opt,name=source_snapshot_id,json=sourceSnapshotId,proto3,oneof"`
}
...
type Disk struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
...
// Types that are assignable to Source:
//
// *Disk_SourceImageId
// *Disk_SourceSnapshotId
Source isDisk_Source `protobuf_oneof:"source"`
}
I see. I think this is the problem. The argument must be a protobuf; otherwise, the default JSON data converter is used. The slice of protobufs is not a protobuf. The solution is to create a wrapper proto that contains a repeated field of Disk type.