Replay a history in the debugger

Hi,

I am working on refining the error parsing/handling logic in my workflow code.

If I remember correctly the demo I saw, it is possible to:

  1. download the history of a workflow (done)
  2. replay this history against the workflow/decision logic.
  3. put break points and tweak the error parsing until it does what I want.

For 2), it seems like I should use worker.ReplayWorkflowHistoryFromJSONFile. So I have written a test case like this what’s at the end of this message. It does not work and I tracked the issue down to the following:

{“error”: “json: cannot unmarshal array into Go value of type map[string]json.RawMessage”}

I must be missing something obvious at this point. The history was downloaded from the console, and I am using temporal 0.26. How do I get past this?

For 3), I am using Goland. I don’t think that should matter, but could you share pointers if there are gotchas?

Thank you,
Jacques

----------------------------------------- Test case below to trigger replay:

package workflow

import (
github.com/stretchr/testify/suite
go.temporal.io/temporal/testsuite
go.temporal.io/temporal/worker
go.uber.org/zap
“testing”
)

// This file is a helper to replay workflow execution code (downloaded from the service or the console)

type UnitTestSuite struct {
suite.Suite
testsuite.WorkflowTestSuite
}

func TestUnitTestSuite(t *testing.T) {
suite.Run(t, new(UnitTestSuite))
}

func (s *UnitTestSuite) Test_Workflow() {
filename := “my_history_file.json”

logger, err := zap.NewDevelopment()
if err != nil {
	panic(err)
}

w := worker.NewWorkflowReplayer()

w.RegisterWorkflow(PatchClusterWorkflow)

w.ReplayWorkflowHistoryFromJSONFile(logger, filename)

}

1 Like

It seems you have old history in JSON file. We currently break JSON format with every version. So please make sure you created JSON file with the same server/sdk/tctl version.

Replay should work, we have integration test for it.

1 Like

Oh, that makes sense. Is there an easy way to tell the versions apart? Right now, I should have everything running 0.26. I’ll double check that, and the pointer you gave me helps.

Thank you,
Jacques

There is no version in json files. We don’t plan to break it in the future. I would recommend to upgrade to latest v0.28.0, re-record history and try to replay it. There was important fix to replayer recently (replayer did not fail on wrong history).