Skip to content

[api-go] Repeated Payload not being visited #1865

@yuandrew

Description

@yuandrew

Expected Behavior

Visitor should visit this repeated temporal.api.common.v1.Payload https://github.com/temporalio/api/blob/9156239c8272003b6f228951602ca2b130a55876/temporal/api/workflowservice/v1/request_response.proto#L938

This test should pass

func TestVisitPayloads_AggregationGroup(t *testing.T) {
	// Due to us not visiting protos inside Any, this test used to fail
	root := &workflowservice.CountWorkflowExecutionsResponse_AggregationGroup{GroupValues: []*common.Payload{{Data: []byte("orig-val")}}}

	var count int
	// Visit with any recursion enabled and only change orig-val
	err := VisitPayloads(context.Background(), root, VisitPayloadsOptions{
		Visitor: func(ctx *VisitPayloadsContext, p []*common.Payload) ([]*common.Payload, error) {
			count += 1
			// Only mutate if the payloads has orig-val
			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, count)
}

Actual Behavior

Test is failing due to Payload not being visited.

Steps to Reproduce the Problem

Specifications

  • Version:
  • Platform:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions