fix(model): route to custom node when prefix collides with built-in provider alias - #3364
Open
dnd21052002 wants to merge 1 commit into
Open
fix(model): route to custom node when prefix collides with built-in provider alias#3364dnd21052002 wants to merge 1 commit into
dnd21052002 wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When a user creates a custom openai-compatible node whose prefix matches a built-in provider alias, requests to that prefix fail with
No active credentials for provider: <name>.Reproduction:
tokenrouterwith prefixtr(the built-intokenrouterprovider also uses aliastr)tr/qwen/qwen3.8-max-freeNo active credentials for provider: tokenrouterRoot cause: In
src/sse/services/model.js, theRESERVED_PROVIDER_PREFIXESguard skips the custom-node lookup when the prefix matches any built-in provider id/alias. The request is routed to the built-in provider, but the user's credentials are stored under the custom node's ID → credential lookup returns 0 results.This is a regression of #1756 (same symptom, same root cause pattern).
Fix
Check custom provider nodes first. If the user explicitly created a node with a given prefix, route to it even when the prefix collides with a built-in provider id/alias. Only fall through to built-in provider resolution when no custom node matches.
This is the correct precedence: explicit user configuration (a created node + stored credentials) should always win over implicit built-in defaults.
Changes
src/sse/services/model.js— removeRESERVED_PROVIDER_PREFIXESguard; always check custom nodes before falling back to built-in resolutiontests/unit/model-routing.test.js— update collision test to assert custom-node-first behavior; add regression test for thetr/tokenrouter caseTesting
still routes non-reserved compatible node prefixesstill passes (unchanged behavior for non-colliding prefixes)cf(cloudflare-ai) aliastr/tokenrouter scenario from the bug report