fix: custom provider prefix conflicts with built-in alias

When a custom OpenAI-compatible provider uses a prefix that matches
a built-in alias (e.g. 'ark' -> 'volcengine-ark'), resolveProviderAlias()
converts it to the built-in provider ID, causing the provider-node
matching logic to be skipped. The request is then routed to the wrong
provider, resulting in a 404 model_not_found error.

Fix: always check provider-node prefix matching using the original
user input (parsed.providerAlias) before falling back to the resolved
alias, regardless of whether resolveProviderAlias() transformed it.

Co-authored-by: H1d3rOne <H1d3rOne@users.noreply.github.com>
Made-with: Cursor
This commit is contained in:
H1d3rOne
2026-05-01 16:28:51 +07:00
committed by decolua
parent 30b114ab75
commit 860d94732a

View File

@@ -19,27 +19,23 @@ export async function getModelInfo(modelStr) {
const parsed = parseModel(modelStr); const parsed = parseModel(modelStr);
if (!parsed.isAlias) { if (!parsed.isAlias) {
if (parsed.provider === parsed.providerAlias) { // Always check provider-node prefix matching using original input first
// Check OpenAI Compatible nodes const openaiNodes = await getProviderNodes({ type: "openai-compatible" });
const openaiNodes = await getProviderNodes({ type: "openai-compatible" }); const matchedOpenAI = openaiNodes.find((node) => node.prefix === parsed.providerAlias);
const matchedOpenAI = openaiNodes.find((node) => node.prefix === parsed.providerAlias); if (matchedOpenAI) {
if (matchedOpenAI) { return { provider: matchedOpenAI.id, model: parsed.model };
return { provider: matchedOpenAI.id, model: parsed.model }; }
}
// Check Anthropic Compatible nodes const anthropicNodes = await getProviderNodes({ type: "anthropic-compatible" });
const anthropicNodes = await getProviderNodes({ type: "anthropic-compatible" }); const matchedAnthropic = anthropicNodes.find((node) => node.prefix === parsed.providerAlias);
const matchedAnthropic = anthropicNodes.find((node) => node.prefix === parsed.providerAlias); if (matchedAnthropic) {
if (matchedAnthropic) { return { provider: matchedAnthropic.id, model: parsed.model };
return { provider: matchedAnthropic.id, model: parsed.model }; }
}
// Check Custom Embedding nodes const embeddingNodes = await getProviderNodes({ type: "custom-embedding" });
const embeddingNodes = await getProviderNodes({ type: "custom-embedding" }); const matchedEmbedding = embeddingNodes.find((node) => node.prefix === parsed.providerAlias);
const matchedEmbedding = embeddingNodes.find((node) => node.prefix === parsed.providerAlias); if (matchedEmbedding) {
if (matchedEmbedding) { return { provider: matchedEmbedding.id, model: parsed.model };
return { provider: matchedEmbedding.id, model: parsed.model };
}
} }
return { return {
provider: parsed.provider, provider: parsed.provider,