-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
fix(providers): refresh model list after provider sync #3402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
diegosouzapw
merged 11 commits into
diegosouzapw:release/v3.8.16
from
0xtbug:feat-auto-sync-models
Jun 8, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
79b5d4e
feat(providers): implement bulk paste for extra API keys
0xtbug f671f8c
refactor(providers): streamline API key bulk paste and i18n
0xtbug a1dfe9b
perf(logs): fix browser freeze and network saturation on /dashboard/logs
0xtbug 682ad8c
fix(logs): apply code review feedback - robust signature, immediate f…
0xtbug 1d692d4
Merge remote-tracking branch 'origin/release/v3.8.9' into 0xtbug/main
diegosouzapw e54eb82
test(logs): extract pure polling/signature helpers + cover them (#3109)
diegosouzapw 41ec239
Merge branch 'diegosouzapw:main' into main
0xtbug 28d2d1e
feat(providers): auto-sync models if local catalog is empty for a pro…
0xtbug 43bfd58
fix(providers): apply review suggestion for cancelled requests
0xtbug 0e9d832
Merge remote-tracking branch 'origin/release/v3.8.16' into feat-auto-…
diegosouzapw 6eb2e52
test(providers): add regression tests for connection-ID models route …
0xtbug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /** | ||
| * Tests for GET /api/v1/providers/[provider]/models | ||
| * Covers the connection-ID fallback path added in PR #3402. | ||
| * | ||
| * Run: node --import tsx/esm --test tests/unit/provider-models-v1-route.test.ts | ||
| */ | ||
|
|
||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
|
|
||
| const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-v1-provider-models-")); | ||
| process.env.DATA_DIR = TEST_DATA_DIR; | ||
|
|
||
| const core = await import("../../src/lib/db/core.ts"); | ||
| const routeModule = await import( | ||
| "../../src/app/api/v1/providers/[provider]/models/route.ts" | ||
| ); | ||
|
|
||
| function makeRequest(provider: string) { | ||
| return new Request(`http://localhost/api/v1/providers/${encodeURIComponent(provider)}/models`); | ||
| } | ||
|
|
||
| async function callGET(provider: string) { | ||
| return routeModule.GET(makeRequest(provider), { | ||
| params: Promise.resolve({ provider }), | ||
| }); | ||
| } | ||
|
|
||
| test.beforeEach(() => { | ||
| core.resetDbInstance(); | ||
| }); | ||
|
|
||
| test.after(() => { | ||
| core.resetDbInstance(); | ||
| fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| test("GET /v1/providers/:provider/models returns 400 for completely unknown provider", async () => { | ||
| const res = await callGET("utterly-unknown-provider-xyz"); | ||
| assert.equal(res.status, 400); | ||
| const body = await res.json(); | ||
| assert.equal(body.error?.code, "invalid_provider"); | ||
| assert.ok(body.error?.message?.includes("utterly-unknown-provider-xyz")); | ||
| }); | ||
|
|
||
| test("GET /v1/providers/:provider/models accepts openai-compatible connection ID format", async () => { | ||
| const connectionId = "openai-compatible-chat-a1b2c3d4-e5f6-7890-abcd-ef1234567890"; | ||
| // A valid compatible connection ID should NOT return 400 (passes validation gate) | ||
| const res = await callGET(connectionId); | ||
| // The catalog may return 200 with empty data or non-200 for other reasons, | ||
| // but it must NOT return the "Unknown provider" 400 error. | ||
| if (res.status === 400) { | ||
| const body = await res.json(); | ||
| assert.notEqual( | ||
| body.error?.code, | ||
| "invalid_provider", | ||
| "openai-compatible-chat-* IDs must bypass the unknown-provider 400 gate" | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| test("GET /v1/providers/:provider/models accepts anthropic-compatible connection ID format", async () => { | ||
| const connectionId = "anthropic-compatible-chat-deadbeef-0000-0000-0000-000000000000"; | ||
| const res = await callGET(connectionId); | ||
| if (res.status === 400) { | ||
| const body = await res.json(); | ||
| assert.notEqual(body.error?.code, "invalid_provider"); | ||
| } | ||
| }); | ||
|
|
||
| test("GET /v1/providers/:provider/models rejects non-matching connection-like strings", async () => { | ||
| // Looks like a connection ID but with wrong prefix | ||
| const res = await callGET("custom-compatible-chat-a1b2c3d4-e5f6-7890-abcd-ef1234567890"); | ||
| assert.equal(res.status, 400); | ||
| const body = await res.json(); | ||
| assert.equal(body.error?.code, "invalid_provider"); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.