Merge pull request #5832 from stephanmck/fix/provider-error-body-passthrough-5763

fix(ai): surface provider HTTP error body instead of opaque SDK message
This commit is contained in:
Mario Zechner
2026-06-29 16:58:24 +02:00
committed by GitHub
12 changed files with 580 additions and 36 deletions
@@ -40,6 +40,7 @@ import {
createAssistantMessageDiagnostic,
formatThrownValue,
} from "../utils/diagnostics.ts";
import { formatProviderError, normalizeProviderError } from "../utils/error-body.ts";
import { AssistantMessageEventStream } from "../utils/event-stream.ts";
import { headersToRecord } from "../utils/headers.ts";
import { resolveHttpProxyUrlForTarget } from "../utils/node-http-proxy.ts";
@@ -396,7 +397,7 @@ export const stream: StreamFunction<"openai-codex-responses", OpenAICodexRespons
delete (block as { partialJson?: string }).partialJson;
}
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
output.errorMessage = error instanceof Error ? error.message : String(error);
output.errorMessage = formatProviderError(normalizeProviderError(error));
stream.push({ type: "error", reason: output.stopReason, error: output });
stream.end();
}