Skip to content

fix: Preserve original URL parsing error cause in getHostAddress()#194

Open
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/preserve-error-cause-in-getHostAddress
Open

fix: Preserve original URL parsing error cause in getHostAddress()#194
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/preserve-error-cause-in-getHostAddress

Conversation

@YunchuWang
Copy link
Member

Fixes #191

Problem

getHostAddress() in DurableTaskAzureManagedClientOptions catches URL parsing errors and re-throws a new Error with a descriptive message, but drops the original error. This makes it difficult to diagnose why a specific endpoint URL is invalid.

Changes

  • Change the catch block to preserve the original error as the cause using { cause: e }
  • Consistent with the error wrapping convention used elsewhere in the codebase (e.g., pb-helper.util.ts:434)

The getHostAddress() method in DurableTaskAzureManagedClientOptions drops the
original URL parsing error when re-throwing, making it difficult to debug why
a specific endpoint URL is invalid. This change preserves the original error
as the cause property of the new Error.

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

This PR improves debuggability of Azure Managed SDK endpoint configuration by preserving the original URL parsing error when getHostAddress() rejects an invalid endpoint, aligning with existing error-wrapping patterns in the repo.

Changes:

  • Preserve the original URL parsing exception by rethrowing with new Error(..., { cause: e }) in getHostAddress().
  • Add a unit test asserting that the thrown error includes a defined cause.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/durabletask-js-azuremanaged/src/options.ts Wrap URL parsing failures with { cause } so the original parsing error is retained.
packages/durabletask-js-azuremanaged/test/unit/options.spec.ts Adds a test to validate that getHostAddress() preserves the underlying parsing error as cause.


try {
options.getHostAddress();
fail("Expected getHostAddress to throw");
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The test calls fail("Expected getHostAddress to throw"), but this repo's Jest setup uses the default jest-circus runner (no jest-jasmine2), where fail is not a guaranteed global and can cause a ReferenceError, failing the suite. Prefer throwing an Error in that branch (or structure the test to capture the thrown error without relying on fail).

Suggested change
fail("Expected getHostAddress to throw");
throw new Error("Expected getHostAddress to throw");

Copilot uses AI. Check for mistakes.
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: getHostAddress() drops original URL parsing error cause

2 participants