-
Notifications
You must be signed in to change notification settings - Fork 11
[copilot-finds] Bug: Missing CANCELED member in OrchestrationStatus enum causes client crashes #203
Description
Problem
The client-facing OrchestrationStatus enum in packages/durabletask-js/src/orchestration/enum/orchestration-status.enum.ts (line 27-35) is missing the CANCELED member, even though the protobuf definition includes ORCHESTRATION_STATUS_CANCELED = 4.
This causes fromProtobuf() to throw "Unknown protobuf OrchestrationStatus value: 4" when encountering any orchestration with the CANCELED status. Since fromProtobuf() is called by newOrchestrationState(), this crashes every client operation that reads orchestration state:
getOrchestration()waitForOrchestrationCompletion()getAllInstances()/listInstances()
Additionally:
InMemoryOrchestrationBackend.toClientStatus()silently maps CANCELED to RUNNING (incorrect)isTerminalStatus()in bothInMemoryOrchestrationBackendandTestOrchestrationClientdoes not include CANCELED, sowaitForCompletion()never returns for canceled orchestrations in the test backend
Root Cause
When the OrchestrationStatus enum was defined, the CANCELED member was omitted. All other proto status values (RUNNING, COMPLETED, CONTINUED_AS_NEW, FAILED, TERMINATED, PENDING, SUSPENDED) have corresponding client enum members, but ORCHESTRATION_STATUS_CANCELED = 4 does not.
Proposed Fix
- Add
CANCELED = pb.OrchestrationStatus.ORCHESTRATION_STATUS_CANCELEDto theOrchestrationStatusenum (the existing initialization loop auto-registers it in conversion maps) - Add CANCELED case to
InMemoryOrchestrationBackend.toClientStatus() - Add CANCELED to
isTerminalStatus()in bothInMemoryOrchestrationBackendandTestOrchestrationClient - Add comprehensive tests for OrchestrationStatus enum conversions
Impact
Severity: Medium-High. Any orchestration that enters the CANCELED state (via the sidecar, another SDK, or future API) would cause the JS client to crash with an unhandled error when querying or listing orchestrations. This prevents interop with other SDKs that may use the CANCELED status.