Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/durabletask-js-azuremanaged/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ abstract class DurableTaskAzureManagedOptionsBase {
authority = `${authority}:${url.port}`;
}
return authority;
} catch {
throw new Error(`Invalid endpoint URL: ${endpoint}`);
} catch (e) {
throw new Error(`Invalid endpoint URL: ${endpoint}`, { cause: e });
}
}

Expand Down
17 changes: 17 additions & 0 deletions packages/durabletask-js-azuremanaged/test/unit/options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ describe("Options", () => {

expect(() => options.getHostAddress()).toThrow("Invalid endpoint URL:");
});

it("should preserve the original error as cause when URL parsing fails", () => {
const options = new DurableTaskAzureManagedClientOptions().setEndpointAddress("invalid:url");

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.
} catch (e: unknown) {
expect(e).toBeInstanceOf(Error);
const error = e as Error;
expect(error.message).toContain("Invalid endpoint URL:");
expect(error.cause).toBeDefined();
// The cause should be the original URL parsing error
expect((error.cause as Error).message).toBeDefined();
expect((error.cause as Error).message.length).toBeGreaterThan(0);
}
});
});

describe("createChannelCredentials", () => {
Expand Down
Loading