Skip to content

fix: Align TestOrchestrationClient null serialization with TaskHubGrpcClient#199

Open
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-test-client-null-serialization
Open

fix: Align TestOrchestrationClient null serialization with TaskHubGrpcClient#199
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-test-client-null-serialization

Conversation

@YunchuWang
Copy link
Member

Fixes #186

Problem

TestOrchestrationClient.raiseOrchestrationEvent and terminateOrchestration handle null data differently from the real TaskHubGrpcClient, causing behavioral divergence between test and production environments. The test client skips serialization for null, while the real client always serializes (null becomes the string 'null').

Changes

  • Change both methods to unconditionally call JSON.stringify(data), matching the real client
  • Ensures test and production environments behave identically for null values

…ivergence from real client

TestOrchestrationClient.raiseOrchestrationEvent and terminateOrchestration
handle null values differently from the real TaskHubGrpcClient, causing
behavioral divergence between test and production environments.

Real client (TaskHubGrpcClient): Always calls JSON.stringify(data), which
turns null into the string "null". The sidecar stores this, and the
orchestrator receives null when deserializing.

Test client (TestOrchestrationClient): Skipped serialization for null with
'data !== null ? JSON.stringify(data) : undefined', which caused the
orchestrator to receive undefined instead of null.

This fix aligns the test client with the real client by unconditionally
serializing the data, so orchestrations tested with the in-memory backend
receive the same values they would in production.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 23, 2026 22:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns the in-memory TestOrchestrationClient serialization semantics with the production TaskHubGrpcClient, eliminating a test-vs-prod behavioral mismatch for null event payloads and termination output.

Changes:

  • Update TestOrchestrationClient.raiseOrchestrationEvent() to always JSON.stringify(data) (including null).
  • Update TestOrchestrationClient.terminateOrchestration() to always JSON.stringify(output) (including null).
  • Add Jest regression tests validating null (and other falsy) payload round-tripping behavior in the in-memory test stack.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/durabletask-js/src/testing/test-client.ts Makes event/termination payload encoding match production behavior by always stringifying null.
packages/durabletask-js/test/test-client-serialization.spec.ts Adds coverage to ensure null (and other falsy values) are delivered/stored consistently in tests.

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.

[copilot-finds] Bug: TestOrchestrationClient serializes null values differently from TaskHubGrpcClient

2 participants