API to run a workflow with custom context?

I see that my custom context for a workflow instance is saved here


How do I invoke a new workflow using the newUntypedWorkflowStub api and passing in the context of existing workflow? i.e. untypedWorkflowStub.start(args)

My objective is to update an existing workflow input, and rerun it. Trying to accomplish this by creating a new workflow using newUntypedWorkflowStub, but if there is a way to update existing workflow’s input using another api and then use resetWorkflowExecution api, that would work too. But I’m not sure there is a way to update the input on a failed workflow hence I am trying to create a new workflow but need the context that was used.

I am trying to create a new workflow but need the context that was used

If the context is exposed via query method in the completed workflow, you could get it via query (you can query completed workflow executions up to the set namespace retention period) and pass it as input to your new execution.
If it’s not exposed via query handler, you can get the inputs of a workflow execution via api as shown in this forum thread, and then use them to pass to the new execution.

But how do I pass it in?

Doing the following doesn’t work

myWorkflowStub.start(context, payload);

When I view the workflow started in above fashion in UI I see the input field containing [{the context map}, {the json input}]

while normal workflows input field is [{the json input}]. So I think the context is passed to workflow differently, it can’t be an input parameter.

You use thread local to pass the context to the interceptor.

Figured out the issue, I needed to set the ContextPropagator explicitly when creating WorkflowOptions