Skip to content

Fix OnWorkflow mock to see propagated context headers#2212

Open
kritibehl wants to merge 1 commit intotemporalio:masterfrom
kritibehl:fix-2005-clean
Open

Fix OnWorkflow mock to see propagated context headers#2212
kritibehl wants to merge 1 commit intotemporalio:masterfrom
kritibehl:fix-2005-clean

Conversation

@kritibehl
Copy link
Contributor

@kritibehl kritibehl commented Mar 2, 2026

What was changed

Updated the testsuite OnWorkflow mock execution path to ensure propagated workflow headers are visible to mock matchers.

Specifically, after creating ctxCopy via newWorkflowContext(...), the testsuite now applies:

workflowContextWithHeaderPropagated(ctxCopy, w.env.header, w.env.GetContextPropagators())

before invoking getWorkflowMockReturn(...).

Why?

Issue #2005 reports that OnWorkflow mock matchers cannot observe headers propagated via workflow context propagators, even though real child workflow execution correctly sees them.

Root cause:
The testsuite creates a copied workflow context (ctxCopy) for mock execution, but did not apply header propagation to that context. As a result, propagated values were missing when evaluating OnWorkflow matchers.

This change ensures the mock receives the same header-propagated workflow context as real workflow execution, restoring expected behavior and consistency.

Checklist

1.Closes #2005

  1. How was this tested:
    How was this tested:

go test ./... -count=1

go test ./... -race -count=1

Verified that the change does not impact existing tests.

  1. Any docs updates needed?
    No documentation changes required (testsuite behavioral consistency fix).

@yuandrew
Copy link
Contributor

yuandrew commented Mar 5, 2026

Thanks for the contribution, could we write a test to verify this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OnWorkflow test mocker doesn't propagate context headers

2 participants