From f7c658efb98985f0f5a9af78409b77d81da646f9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 2 Mar 2026 21:39:37 +0000 Subject: [PATCH] fix(core): resolve post-rebase type errors --- src/commands/oauth-tls-preflight.test.ts | 8 +++++--- src/discord/monitor/agent-components.ts | 2 +- src/pairing/pairing-store.ts | 6 ++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/commands/oauth-tls-preflight.test.ts b/src/commands/oauth-tls-preflight.test.ts index acd36635a6e..0d268292afc 100644 --- a/src/commands/oauth-tls-preflight.test.ts +++ b/src/commands/oauth-tls-preflight.test.ts @@ -10,7 +10,9 @@ describe("runOpenAIOAuthTlsPreflight", () => { }); it("returns ok when OpenAI auth endpoint is reachable", async () => { - const fetchImpl = vi.fn(async () => new Response("", { status: 400 })); + const fetchImpl = vi.fn( + async () => new Response("", { status: 400 }), + ) as unknown as typeof fetch; const result = await runOpenAIOAuthTlsPreflight({ fetchImpl, timeoutMs: 20 }); expect(result).toEqual({ ok: true }); }); @@ -22,7 +24,7 @@ describe("runOpenAIOAuthTlsPreflight", () => { }; cause.code = "UNABLE_TO_GET_ISSUER_CERT_LOCALLY"; throw new TypeError("fetch failed", { cause }); - }); + }) as unknown as typeof fetch; const result = await runOpenAIOAuthTlsPreflight({ fetchImpl: tlsFetchImpl, timeoutMs: 20 }); expect(result).toMatchObject({ ok: false, @@ -38,7 +40,7 @@ describe("runOpenAIOAuthTlsPreflight", () => { "Client network socket disconnected before secure TLS connection was established", ), }); - }); + }) as unknown as typeof fetch; const result = await runOpenAIOAuthTlsPreflight({ fetchImpl: networkFetchImpl, timeoutMs: 20, diff --git a/src/discord/monitor/agent-components.ts b/src/discord/monitor/agent-components.ts index f30382a42a8..b72b5a34ebc 100644 --- a/src/discord/monitor/agent-components.ts +++ b/src/discord/monitor/agent-components.ts @@ -870,7 +870,7 @@ async function dispatchDiscordComponentEvent(params: { allowFrom: channelConfig?.users ?? guildInfo?.users, normalizeEntry: (entry) => { const normalized = normalizeDiscordAllowList([entry], ["discord:", "user:", "pk:"]); - const candidate = normalized?.[0]; + const candidate = normalized?.ids.values().next().value; return candidate && /^\d+$/.test(candidate) ? candidate : undefined; }, }) diff --git a/src/pairing/pairing-store.ts b/src/pairing/pairing-store.ts index b7840d33181..57365030f50 100644 --- a/src/pairing/pairing-store.ts +++ b/src/pairing/pairing-store.ts @@ -365,6 +365,9 @@ async function readAllowFromStateForPathWithExists( if (cachedOrMissing) { return cachedOrMissing; } + if (!stat) { + return { entries: [], exists: false }; + } const { value, exists } = await readJsonFile(filePath, { version: 1, @@ -402,6 +405,9 @@ function readAllowFromStateForPathSyncWithExists( if (cachedOrMissing) { return cachedOrMissing; } + if (!stat) { + return { entries: [], exists: false }; + } let raw = ""; try {