Skip to content

[copilot-finds] Bug: Missing CANCELED member in OrchestrationStatus enum causes client crashes #203

@github-actions

Description

@github-actions

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 both InMemoryOrchestrationBackend and TestOrchestrationClient does not include CANCELED, so waitForCompletion() 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

  1. Add CANCELED = pb.OrchestrationStatus.ORCHESTRATION_STATUS_CANCELED to the OrchestrationStatus enum (the existing initialization loop auto-registers it in conversion maps)
  2. Add CANCELED case to InMemoryOrchestrationBackend.toClientStatus()
  3. Add CANCELED to isTerminalStatus() in both InMemoryOrchestrationBackend and TestOrchestrationClient
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    copilot-findsFindings from daily automated code review agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions