Skip to content

Commit e5a7cdc

Browse files
committed
fix(vllm): guard discovery URL validation
1 parent 1505233 commit e5a7cdc

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

apps/sim/app/api/providers/vllm/models/route.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,13 @@ describe('vLLM models route', () => {
6262
})
6363
)
6464
})
65+
66+
it('returns an empty model list when the configured base URL is unsupported', async () => {
67+
setEnv({ VLLM_BASE_URL: 'http://localhost:1234?token=value' })
68+
69+
const response = await GET(request())
70+
71+
await expect(response.json()).resolves.toEqual({ models: [] })
72+
expect(mockFetch).not.toHaveBeenCalled()
73+
})
6574
})

apps/sim/app/api/providers/vllm/models/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export const GET = withRouteHandler(async (_request: NextRequest) => {
2727
logger.info('VLLM_BASE_URL not configured')
2828
return NextResponse.json({ models: [] })
2929
}
30-
const apiBaseUrl = getOpenAICompatibleApiBaseUrl(baseUrl)
3130

3231
try {
32+
const apiBaseUrl = getOpenAICompatibleApiBaseUrl(baseUrl)
3333
logger.info('Fetching vLLM models', {
3434
baseUrl,
3535
})

apps/sim/providers/vllm/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ export const vllmProvider: ProviderConfig = {
5959
logger.info('VLLM_BASE_URL not configured, skipping initialization')
6060
return
6161
}
62-
const apiBaseUrl = getOpenAICompatibleApiBaseUrl(baseUrl)
6362

6463
try {
64+
const apiBaseUrl = getOpenAICompatibleApiBaseUrl(baseUrl)
6565
const headers: Record<string, string> = {
6666
'Content-Type': 'application/json',
6767
}

0 commit comments

Comments
 (0)