mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 15:22:12 +03:00
fix(mcp): remove non-standard x-provider field from omniroute_test_combo body (#9274)
Validated in local merge-train (devbox-vm-06-dev002) @ combined-tip (FAST gates green: static + changed tests + vitest — only pre-existing audit.test.ts flake). Evidence: /home/diegosouzapw/dev/proxys/OmniRoute/.claude/worktrees/merge-train-20260805-213228-suite.log
This commit is contained in:
committed by
GitHub
parent
a4d79c81aa
commit
d61d7f7f95
@@ -9,9 +9,15 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
const mockFetch = vi.fn();
|
||||
vi.stubGlobal("fetch", mockFetch);
|
||||
|
||||
const { handleTestCombo } = await import("../tools/advancedTools.ts");
|
||||
|
||||
describe("MCP Advanced Tools", () => {
|
||||
beforeEach(() => {
|
||||
mockFetch.mockReset();
|
||||
// Re-assert the stub: importing advancedTools.ts triggers OmniRoute's own
|
||||
// startup side effects (DB init, global fetch proxy patch) that overwrite
|
||||
// globalThis.fetch after the top-level vi.stubGlobal() above ran.
|
||||
vi.stubGlobal("fetch", mockFetch);
|
||||
});
|
||||
|
||||
describe("simulate_route", () => {
|
||||
@@ -82,6 +88,32 @@ describe("MCP Advanced Tools", () => {
|
||||
expect(combo).toBeDefined();
|
||||
expect(combo.models).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("does not send a non-standard 'x-provider' body field upstream (regression, strict providers like Groq reject it with HTTP 400)", async () => {
|
||||
mockFetch
|
||||
.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => [
|
||||
{
|
||||
id: "groq-combo",
|
||||
models: [{ provider: "groq", model: "groq/llama-3.1-8b-instant" }],
|
||||
},
|
||||
],
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({ model: "llama-3.1-8b-instant", cost: 0, usage: {} }),
|
||||
});
|
||||
|
||||
await handleTestCombo({ comboId: "groq-combo", testPrompt: "hi" });
|
||||
|
||||
const chatCompletionsCall = mockFetch.mock.calls.find(([url]) =>
|
||||
String(url).includes("/v1/chat/completions")
|
||||
);
|
||||
expect(chatCompletionsCall).toBeDefined();
|
||||
const sentBody = JSON.parse(chatCompletionsCall![1].body);
|
||||
expect(sentBody).not.toHaveProperty("x-provider");
|
||||
});
|
||||
});
|
||||
|
||||
describe("get_provider_metrics", () => {
|
||||
|
||||
@@ -548,7 +548,6 @@ export async function handleTestCombo(args: { comboId: string; testPrompt: strin
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
max_tokens: 50,
|
||||
stream: false,
|
||||
"x-provider": model.provider,
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user