-
Notifications
You must be signed in to change notification settings - Fork 255
Closed
temporalio/api-go
#215Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
Today our Payload visitor will visit Any fields, but we don't properly visit and parse through a map of Any's, i.e. this repeated Any field in our API.
Describe the solution you'd like
This test should pass.
func TestVisitPayloads_ArrayAny(t *testing.T) {
msg, err := anypb.New(&update.Request{Input: &update.Input{Args: &common.Payloads{
Payloads: []*common.Payload{{Data: []byte("orig-val")}},
}}})
require.NoError(t, err)
root := &errordetails.MultiOperationExecutionFailure_OperationStatus{Details: []*anypb.Any{msg}}
var anyCount int
err = VisitPayloads(context.Background(), root, VisitPayloadsOptions{
Visitor: func(ctx *VisitPayloadsContext, p []*common.Payload) ([]*common.Payload, error) {
anyCount++
// Only mutate if the payloads has "test"
if len(p) == 1 && string(p[0].Data) == "orig-val" {
return []*common.Payload{{Data: []byte("new-val")}}, nil
}
return p, nil
},
})
require.NoError(t, err)
require.Equal(t, 1, anyCount)
update1, err := root.Details[0].UnmarshalNew()
require.NoError(t, err)
require.Equal(t, "new-val", string(update1.(*update.Request).Input.Args.Payloads[0].Data))
}
Likely will require enhancing or creating a new case here https://github.com/temporalio/api-go/blob/4c00816d0d87af129f51a33be6f3b2ca20e3ccb7/cmd/proxygenerator/interceptor.go#L262
Additional context
Add any other context or screenshots about the feature request here.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request