Decoding protobuf message containing oneof field

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)

More details can be seen in the demo: GitHub - odyfey/temporal-decode-oneof-demo

It looks like the problem is not specifically related to ProtoJSONPayloadConverter, since the test with this converter passes successfully.

Changing parameters such as AllowUnknowsFields in ProtoJSONPayloadConverterOptions does not solve the problem.

A workaround may be to return a custom structure (not protobuf) from the activity, but maybe there is a more elegant solution to this problem?

Are you sure you are returning the protobuf structure and not a custom structure containing a protobuf as a field?

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"` 
}

Clarification: the problem occurs when returning a slice of protobuf structures []*compute.Disk, in the case of a single element everything is ok.

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.