Skip to content

fix: add missing CANCELED orchestration status#307

Closed
YunchuWang wants to merge 2 commits into
microsoft:mainfrom
YunchuWang:copilot-finds/bug/missing-canceled-orchestration-status
Closed

fix: add missing CANCELED orchestration status#307
YunchuWang wants to merge 2 commits into
microsoft:mainfrom
YunchuWang:copilot-finds/bug/missing-canceled-orchestration-status

Conversation

@YunchuWang

Copy link
Copy Markdown
Member

Summary

  • Expose the protobuf CANCELED status through the public orchestration status enum.
  • Treat canceled in-memory orchestrations as terminal and map their client status correctly.
  • Add conversion and in-memory backend coverage.

Fixes #203

Testing

  • npm test -w @microsoft/durabletask-js -- --runTestsByPath test/orchestration-status.spec.ts test/in-memory-backend.spec.ts
  • npm run build:core

Copilot AI and others added 2 commits March 26, 2026 08:50
…us enum

The client-facing OrchestrationStatus enum was missing the CANCELED member
even though the protobuf definition includes ORCHESTRATION_STATUS_CANCELED (4).
This caused fromProtobuf() to throw 'Unknown protobuf OrchestrationStatus
value: 4' when encountering canceled orchestrations, crashing any client call
that reads orchestration state (getOrchestration, waitForCompletion,
getAllInstances).

Changes:
- Add CANCELED to OrchestrationStatus enum (auto-registers in conversion maps)
- Add CANCELED case to InMemoryOrchestrationBackend.toClientStatus()
- Add CANCELED to isTerminalStatus() in both InMemoryOrchestrationBackend and
  TestOrchestrationClient
- Add comprehensive tests for OrchestrationStatus enum round-trip conversions
- Add toClientStatus tests to in-memory backend spec

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve the in-memory backend test conflict while preserving current main coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d175a43f-c852-49a2-a0de-63db579a8e3a
Copilot AI review requested due to automatic review settings July 17, 2026 16:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a client crash and incorrect in-memory behavior by exposing the protobuf CANCELED orchestration status through the public OrchestrationStatus enum, and ensuring canceled orchestrations are treated as terminal in the test/in-memory backend.

Changes:

  • Add CANCELED to the public OrchestrationStatus enum and rely on existing conversion-map initialization.
  • Update in-memory backend status mapping and terminal-status checks to include CANCELED.
  • Add/extend Jest coverage for status conversion and in-memory backend status mapping.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/durabletask-js/src/orchestration/enum/orchestration-status.enum.ts Adds CANCELED to the public status enum to align with protobuf and prevent conversion crashes.
packages/durabletask-js/src/testing/in-memory-backend.ts Maps protobuf CANCELED to client CANCELED and treats it as terminal in the in-memory backend.
packages/durabletask-js/src/testing/test-client.ts Treats protobuf CANCELED as terminal so waitForCompletion can return for canceled instances.
packages/durabletask-js/test/orchestration-status.spec.ts Adds conversion/round-trip/completeness tests for status enum mappings, including CANCELED.
packages/durabletask-js/test/in-memory-backend.spec.ts Adds regression coverage for toClientStatus mapping of CANCELED.

Comment on lines +64 to +66
it("should cover all non-zero proto OrchestrationStatus values", () => {
// Get all numeric values from the proto enum (protobuf JS enums are plain objects)
const protoValues = new Set<number>();
Comment on lines +606 to +609
it("should map CANCELED proto status to CANCELED client status", () => {
const { OrchestrationStatus: pbStatus } = require("../src/proto/orchestrator_service_pb");
expect(backend.toClientStatus(pbStatus.ORCHESTRATION_STATUS_CANCELED)).toBe(OrchestrationStatus.CANCELED);
});
Comment on lines +611 to +622
it("should map all known proto statuses without throwing", () => {
const { OrchestrationStatus: pbStatus } = require("../src/proto/orchestrator_service_pb");
const protoStatuses = [
pbStatus.ORCHESTRATION_STATUS_RUNNING,
pbStatus.ORCHESTRATION_STATUS_COMPLETED,
pbStatus.ORCHESTRATION_STATUS_CONTINUED_AS_NEW,
pbStatus.ORCHESTRATION_STATUS_FAILED,
pbStatus.ORCHESTRATION_STATUS_CANCELED,
pbStatus.ORCHESTRATION_STATUS_TERMINATED,
pbStatus.ORCHESTRATION_STATUS_PENDING,
pbStatus.ORCHESTRATION_STATUS_SUSPENDED,
];
@YunchuWang

Copy link
Copy Markdown
Member Author

Closing as not an active bug. A cross-SDK/backend check shows nothing currently produces ORCHESTRATION_STATUS_CANCELED (value 4): durabletask-go defines the constant and treats it as terminal in IsComplete() but never assigns it; .NET (DurableTask.Core / AzureStorage) references it only in comparisons; Python has it only in generated proto; and the durabletask-js worker only ever emits COMPLETED/FAILED/TERMINATED. Because no backend emits status 4, fromProtobuf(4) is never reached and the described client crash cannot occur in practice. This is a latent/defensive concern rather than a reproducible failure, so closing for now. The deeper fragility (that fromProtobuf throws on any unmapped proto status) can be revisited separately if graceful degradation is desired.

@YunchuWang YunchuWang closed this Jul 17, 2026
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: Missing CANCELED member in OrchestrationStatus enum causes client crashes

3 participants