Skip to content

Conversation

@mfateev
Copy link
Member

@mfateev mfateev commented Jan 7, 2026

Summary

  • Fix test server to throw INVALID_ARGUMENT: UnhandledCommand error for UNHANDLED_COMMAND, matching real Temporal server behavior
  • Add registry.clear() in MetricsTest setUp for clean state between tests

Problem

The MetricsTest.testUnhandledCommand test was flaky because completion metrics were being double-counted. The real Temporal server returns INVALID_ARGUMENT error when a workflow task has unhandled commands, which prevents the SDK from applying metrics. The test server was silently recording the failure in history but returning success to the caller, causing the SDK to apply metrics before learning (during replay) that the task was rejected.

Solution

Make the test server throw INVALID_ARGUMENT: UnhandledCommand to match real server behavior. This was validated by running the test against a real Temporal server first.

Test plan

  • MetricsTest.testUnhandledCommand passes against real Temporal server
  • MetricsTest.testUnhandledCommand passes against test server with fix
  • All MetricsTest tests pass (7/7)

The real Temporal server returns INVALID_ARGUMENT error when a workflow
task has unhandled commands. The test server was silently recording the
failure in history but returning success to the caller, causing the SDK
to apply completion metrics before learning the task was rejected.

This fix makes the test server throw INVALID_ARGUMENT: UnhandledCommand
to match real server behavior, preventing double-counted metrics.

Also adds registry.clear() in MetricsTest setUp for clean state.
@mfateev mfateev requested a review from a team as a code owner January 7, 2026 05:11
@mfateev mfateev merged commit 2322bd0 into temporalio:master Jan 7, 2026
15 checks passed
@mfateev mfateev deleted the task/metricstest-flake branch January 7, 2026 21:27
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.

2 participants