Skip to content

fix: Preserve failure details when error message or type is empty string#198

Open
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-failure-details-empty-message
Open

fix: Preserve failure details when error message or type is empty string#198
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-failure-details-empty-message

Conversation

@YunchuWang
Copy link
Member

Fixes #187

Problem

newOrchestrationState silently drops FailureDetails when either the error message or error type is an empty string, due to JavaScript falsy string checks. Also uses .toString() instead of .getValue() for stack trace extraction.

Changes

  • Replace falsy string checks with a null check on the TaskFailureDetails protobuf object itself
  • Fix getStacktrace()?.toString() to getStacktrace()?.getValue() for consistency with the rest of the codebase
  • Matches the pattern already used in client.ts and history-event-converter.ts

… error message or type is empty string

The newOrchestrationState function in orchestration/index.ts used falsy string
checks (failureDetailsErrorMessage && failureDetailsErrorType) to determine
whether to create FailureDetails. Empty strings are falsy in JavaScript, so
failure details with an empty error message or empty error type were silently
dropped, returning undefined failureDetails even for failed orchestrations.

This fix changes the check to verify the protobuf TaskFailureDetails object
exists (consistent with the pattern used in client.ts and
history-event-converter.ts). Also fixes getStacktrace()?.toString() to use
the canonical .getValue() method used everywhere else in the codebase.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 23, 2026 22:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a client-side bug in the DurableTask JavaScript SDK where newOrchestrationState() could drop FailureDetails when the protobuf error message/type is an empty string, and aligns stack-trace extraction with the rest of the codebase.

Changes:

  • Preserve FailureDetails based on presence of the protobuf TaskFailureDetails message (not truthiness of its string fields).
  • Extract stack traces via getStacktrace()?.getValue() instead of toString().
  • Add unit tests covering empty-string failure details and stack-trace handling.

Reviewed changes

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

File Description
packages/durabletask-js/src/orchestration/index.ts Fixes failure-details extraction logic to preserve empty-string fields and uses getValue() for stack traces.
packages/durabletask-js/test/new-orchestration-state.spec.ts Adds targeted Jest coverage for the failure-details preservation scenarios (including empty strings).
package-lock.json Contains lockfile metadata changes unrelated to the functional fix.

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: newOrchestrationState drops failure details when error message or type is empty string

2 participants