Skip to content

[copilot-finds] Bug: raiseIfFailed() does not check runtimeStatus, silently succeeds for failed orchestrations without failure details #204

@github-actions

Description

@github-actions

Problem

OrchestrationState.raiseIfFailed() in packages/durabletask-js/src/orchestration/orchestration-state.ts only checks whether this.failureDetails is present to decide whether to throw. It does not check this.runtimeStatus.

This means that when an orchestration has runtimeStatus === OrchestrationStatus.FAILED but its failure details were dropped or missing, raiseIfFailed() silently returns without throwing — giving callers a false sense of success.

Root Cause

The method body:

raiseIfFailed(): void {
  if (this.failureDetails) {
    throw new OrchestrationFailedError(...);
  }
}

It only branches on this.failureDetails, which is optional and can be undefined even when the orchestration actually failed. Failure details can be dropped when the sidecar returns empty strings for the error message or error type (see #187).

Proposed Fix

Add a secondary check: if this.runtimeStatus === OrchestrationStatus.FAILED and failureDetails is not present, throw OrchestrationFailedError with synthetic failure details ("Unknown error" / "UnknownError"). The existing code path with real failure details takes priority.

Impact

Severity: Medium-High. Any user calling raiseIfFailed() to gate downstream logic on orchestration success would silently proceed with failed orchestration results. This is a public API method referenced in examples and documentation.

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