mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
agy's gemini-3.1-pro-high/-low had no alias, so resolveAntigravityModelId sent the
speculative -high/-low suffix verbatim to upstream, which rejects it (400) for
gemini-3.x. Worse, the non-stream executor branch fed the 4xx response into the SSE
collector, returning a synthetic empty {object:chat.completion} envelope that masked
the error. Alias both to gemini-3.1-pro, and surface real upstream errors via
buildErrorBody for non-ok non-stream responses. + unit tests.
26 lines
941 B
TypeScript
26 lines
941 B
TypeScript
/**
|
|
* Build a sanitized OpenAI-style error body for a non-ok Antigravity/agy upstream
|
|
* response (#3229).
|
|
*
|
|
* The non-streaming executor path previously fed 4xx/5xx responses into the SSE
|
|
* collector, which produced a synthetic `{"object":"chat.completion","content":""}`
|
|
* success envelope — masking the real error. Route non-ok responses through
|
|
* `buildErrorBody` instead so the client sees a proper error (hard rule #12).
|
|
*/
|
|
import { buildErrorBody } from "../utils/error.ts";
|
|
|
|
export function buildAntigravityUpstreamError(
|
|
status: number,
|
|
statusText: string,
|
|
rawBody: string
|
|
) {
|
|
let upstreamDetails: unknown;
|
|
try {
|
|
upstreamDetails = JSON.parse(rawBody);
|
|
} catch {
|
|
// upstream body is not JSON (e.g. HTML error page) — omit structured details
|
|
}
|
|
const suffix = statusText ? `: ${statusText}` : "";
|
|
return buildErrorBody(status, `Antigravity upstream error (${status})${suffix}`, upstreamDetails);
|
|
}
|