Skip to content

[copilot-finds] Bug: setOrchestrationStatusFromActions reads error message from result field instead of failureDetails, producing generic span messages for all failed orchestrations #218

@github-actions

Description

@github-actions

Problem

In packages/durabletask-js/src/tracing/trace-helper.ts, the setOrchestrationStatusFromActions() function reads the error message for failed orchestration spans from completeAction.getResult()?.getValue() (line 695).

However, when an orchestration fails, the runtime sets failure information in failureDetails, not in result:

  • setFailed() in runtime-orchestration-context.ts (line 230) calls newCompleteOrchestrationAction(id, FAILED, undefined, failureDetails) — the result parameter is undefined.
  • The worker's error handler in task-hub-grpc-worker.ts similarly creates the action with result = undefined.

This means completeAction.getResult() is always undefined for failed orchestrations, and the span error message always falls through to the generic "Orchestration failed" fallback — losing the actual error message.

Root Cause

The tracing code was written to read from the result field, but the orchestration runtime stores failure information in the failureDetails field (via TaskFailureDetails.errorMessage). These are separate protobuf fields on CompleteOrchestrationAction.

Proposed Fix

Update setOrchestrationStatusFromActions() to read the error message from failureDetails.getErrormessage() first, falling back to result.getValue() for backwards compatibility, then to the default.

Fix the existing test (which artificially set result on the failed action instead of failureDetails) and add tests for the fallback chain.

Impact

Severity: Medium. Every failed orchestration produces a generic "Orchestration failed" OpenTelemetry span message instead of the actual error. This reduces the diagnostic value of traces significantly for debugging orchestration failures.

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