From 79cabcc47014194d6416be3caa139d4523f32b31 Mon Sep 17 00:00:00 2001 From: Stan Date: Tue, 25 Aug 2026 17:10:53 +0500 Subject: [PATCH] include method+URL in AI/ML API OAuth error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Error messages only carried an HTTP status, matching neither this provider's own convention elsewhere nor OpenClaude's aimlapi client (which always labels a failure with the request's origin/path) — made a reported "HTTP 404" impossible to attribute to a specific step without asking the reporter to re-run under a debugger. --- packages/ai/src/auth/oauth/aimlapi.ts | 8 +++++--- packages/ai/test/aimlapi-oauth.test.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/ai/src/auth/oauth/aimlapi.ts b/packages/ai/src/auth/oauth/aimlapi.ts index a41665514a8..d2611f95bf7 100644 --- a/packages/ai/src/auth/oauth/aimlapi.ts +++ b/packages/ai/src/auth/oauth/aimlapi.ts @@ -63,8 +63,10 @@ async function request( options.signal.removeEventListener("abort", onAbort); } + const label = `${method} ${url}`; + if (options.expectJson === false) { - if (!response.ok) throw new Error(`AI/ML API request failed (HTTP ${response.status})`); + if (!response.ok) throw new Error(`AI/ML API request failed: ${label} -> HTTP ${response.status}`); return undefined; } @@ -73,12 +75,12 @@ async function request( const parsed = (await response.json()) as unknown; if (isRecord(parsed)) body = parsed; } catch { - if (response.ok) throw new Error("AI/ML API returned invalid JSON"); + if (response.ok) throw new Error(`AI/ML API returned invalid JSON: ${label}`); } if (!response.ok) { const detail = errorDetail(body); - throw new Error(`AI/ML API request failed (HTTP ${response.status})${detail ? `: ${detail}` : ""}`); + throw new Error(`AI/ML API request failed: ${label} -> HTTP ${response.status}${detail ? `: ${detail}` : ""}`); } return body; } diff --git a/packages/ai/test/aimlapi-oauth.test.ts b/packages/ai/test/aimlapi-oauth.test.ts index 9e26ccc5868..60c2ac38aef 100644 --- a/packages/ai/test/aimlapi-oauth.test.ts +++ b/packages/ai/test/aimlapi-oauth.test.ts @@ -128,7 +128,7 @@ describe.sequential("AI/ML API OAuth", () => { prompt: async () => prompts.shift() ?? "", notify: () => {}, }), - ).rejects.toThrow("AI/ML API request failed (HTTP 400): invalid code"); + ).rejects.toThrow(`AI/ML API request failed: POST ${VERIFY_CODE_URL} -> HTTP 400: invalid code`); }); it("rejects a successful key response that carries no key", async () => {