Skip to content

Commit a003234

Browse files
committed
Fix proxy lookup fallthrough on missing retrieve id
1 parent 8d6d83b commit a003234

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

packages/cli/src/harness-browser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ export async function resolveProxyId(client: Kernel, selector: string): Promise<
6565
if (!trimmed) throw new Error("proxy selector is empty");
6666
try {
6767
const existing = await client.proxies.retrieve(trimmed);
68-
if (existing.id) return existing.id;
68+
if (!existing.id) {
69+
throw new Error(`proxy "${trimmed}" lookup returned no id`);
70+
}
71+
return existing.id;
6972
} catch (err) {
7073
if (!(err instanceof NotFoundError)) {
7174
throw new Error(`looking up proxy "${trimmed}": ${(err as Error).message}`, { cause: err });

packages/cli/test/harness-browser.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ describe("resolveProxyId", () => {
2222
await expect(resolveProxyId(client, "proxy_abc")).resolves.toBe("proxy_abc");
2323
});
2424

25+
it("does not fall back to name matching when retrieve succeeds without an id", async () => {
26+
let listCalled = false;
27+
const client = fakeClient({
28+
retrieve: async () => ({}),
29+
list: async () => {
30+
listCalled = true;
31+
return [{ id: "proxy_1", name: "proxy_abc" }];
32+
},
33+
});
34+
await expect(resolveProxyId(client, "proxy_abc")).rejects.toThrow(/looking up proxy/);
35+
expect(listCalled).toBe(false);
36+
});
37+
2538
it("falls back to a unique name match from the proxy list", async () => {
2639
const client = fakeClient({ list: async () => [{ id: "proxy_1", name: "residential-us" }, { id: "proxy_2", name: "other" }] });
2740
await expect(resolveProxyId(client, "residential-us")).resolves.toBe("proxy_1");

0 commit comments

Comments
 (0)