mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-20 06:02:14 +03:00
- fix #355: increase STREAM_IDLE_TIMEOUT_MS from 60s to 300s to prevent premature stream abortion for extended-thinking models (claude-opus-4-6, o3, etc.) that can pause >60s during reasoning phases. Configurable via STREAM_IDLE_TIMEOUT_MS env var. - fix #350: combo health check test now bypasses REQUIRE_API_KEY=true by sending X-Internal-Test header, recognized in chat.ts auth pipeline to skip API key validation for internal admin-side combo tests. Also extended test timeout from 15s to 20s. Uses OpenAI-compatible format universally (not Claude-style). - fix #346: filter out tools with empty function.name before forwarding to upstream providers. Claude Code sends empty-name tool definitions that cause '400 Invalid input[N].name: empty string' on OpenAI-compat providers. Extends existing message/input empty-name filter.
This commit is contained in:
@@ -49,6 +49,7 @@ export async function POST(request) {
|
||||
const startTime = Date.now();
|
||||
try {
|
||||
// Send a minimal chat request to the internal SSE handler
|
||||
// Use OpenAI-compatible format — universally accepted by all providers via the translator
|
||||
const testBody = {
|
||||
model: modelStr,
|
||||
messages: [{ role: "user", content: "Hi" }],
|
||||
@@ -58,11 +59,15 @@ export async function POST(request) {
|
||||
|
||||
const internalUrl = `${getBaseUrl(request)}/v1/chat/completions`;
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 15000); // 15s timeout
|
||||
const timeout = setTimeout(() => controller.abort(), 20000); // 20s timeout (was 15s, slow providers need more)
|
||||
|
||||
const res = await fetch(internalUrl, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
// Fix #350: bypass REQUIRE_API_KEY for internal admin combo tests
|
||||
"X-Internal-Test": "combo-health-check",
|
||||
},
|
||||
body: JSON.stringify(testBody),
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
@@ -133,7 +133,9 @@ export async function handleChat(request: any, clientRawRequest: any = null) {
|
||||
|
||||
// Optional strict API key mode for /v1 endpoints.
|
||||
// Keep disabled by default to preserve local-mode compatibility.
|
||||
if (process.env.REQUIRE_API_KEY === "true") {
|
||||
// Exception: X-Internal-Test header bypasses auth for admin-side combo health checks (#350)
|
||||
const isInternalTest = request.headers?.get?.("x-internal-test") === "combo-health-check";
|
||||
if (process.env.REQUIRE_API_KEY === "true" && !isInternalTest) {
|
||||
if (!apiKey) {
|
||||
log.warn("AUTH", "Missing API key while REQUIRE_API_KEY=true");
|
||||
return errorResponse(HTTP_STATUS.UNAUTHORIZED, "Missing API key");
|
||||
|
||||
Reference in New Issue
Block a user