Fix test server to return INVALID_ARGUMENT for UNHANDLED_COMMAND #2757
+5
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
INVALID_ARGUMENT: UnhandledCommanderror for UNHANDLED_COMMAND, matching real Temporal server behaviorregistry.clear()in MetricsTest setUp for clean state between testsProblem
The
MetricsTest.testUnhandledCommandtest was flaky because completion metrics were being double-counted. The real Temporal server returnsINVALID_ARGUMENTerror 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: UnhandledCommandto match real server behavior. This was validated by running the test against a real Temporal server first.Test plan
MetricsTest.testUnhandledCommandpasses against real Temporal serverMetricsTest.testUnhandledCommandpasses against test server with fix