Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, resolve } from "node:path";
// Regression guard for "qwen / codebuddy-cn device-code show 'ошибка сервера OmniRoute'".
// The dynamic OAuth GET handler used to swallow EVERY thrown error into a generic
// `{ error: "Internal server error" }` 500, so a device-code upstream failure (qwen.ai /
// copilot.tencent.com — geo-block, outage, bad client) was indistinguishable from a real
// server bug. The fix surfaces the SANITIZED upstream message via sanitizeErrorMessage.
//
// Source-level guard: the route runs inside the Next server (auth + module graph), so a
// behavioural test would need a full request/auth/upstream mock; this pins the exact change.
const here = dirname(fileURLToPath(import.meta.url));
const route = readFileSync(
resolve(here, "../../src/app/api/oauth/[provider]/[action]/route.ts"),
"utf8"
);
test("OAuth GET catch surfaces the sanitized upstream reason, not a bare generic 500", () => {
assert.match(
route,
/const detail = sanitizeErrorMessage\(/,
"the GET catch must sanitize and surface the real error"
);
assert.match(
route,
/error:\s*detail\s*\|\|\s*"Internal server error"/,
"the GET catch must return the sanitized detail (falling back to the generic only when empty)"
);
});