allow catalog opaque providers in unknown models - #4124
Conversation
|
|
|
Warning Review limit reached
More reviews will be available in 40 minutes and 40 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds catalog-opaque provider support to wildcard model allow-lists, enabling requests for uncatalogued self-hosted models (like vLLM) when configured with wildcard access. A new ChangesWildcard Model Allowance with Catalog-Opaque Providers
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Confidence Score: 5/5The change is narrowly scoped to the wildcard + catalog-opaque case; catalog-known providers (OpenAI, Anthropic, etc.) continue to be fully cross-checked, and the blacklist pass runs before the new shortcut on both affected paths. The logic change is minimal and well-contained: a single new predicate gates a previously missing shortcut. The two-pass ordering (blacklist first, then wildcard-opaque) is preserved in both No files require special attention; all changes are in Important Files Changed
Reviews (5): Last reviewed commit: "allow catalog opaque providers in unknow..." | Re-trigger Greptile |
150b8c5 to
03f583a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@framework/modelcatalog/models.go`:
- Around line 248-258: IsCatalogOpaqueProvider currently calls
GetModelsForProvider(provider) and uses len(...)==0 which forces allocation/copy
of the provider slice on the hot request path; change this to an allocation-free
existence/count check by adding and using a lightweight accessor (e.g.,
HasModelsForProvider(provider) bool or GetModelCountForProvider(provider) int)
that scans/reads the underlying index without allocating a full slice, then
replace the len(mc.GetModelsForProvider(provider)) == 0 check with the new
HasModelsForProvider/GetModelCountForProvider call inside
IsCatalogOpaqueProvider; keep the nil mc guard and existing logic otherwise.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8c2fb72e-0de2-4878-ad6c-b6b925af1be3
📒 Files selected for processing (3)
framework/modelcatalog/models.goplugins/governance/httptransportprehook_test.goplugins/governance/resolver_test.go
03f583a to
fd4768c
Compare
fd4768c to
72124ed
Compare
Merge activity
|
## Summary This is a hotfix release (v1.5.10) on top of v1.5.9 that addresses two targeted bugs in governance and provider model allow-listing. No new features, migrations, or behavioral opt-ins are introduced beyond the explicit opt-in flag described below. ## Changes - **Virtual key usage dropped under user attribution (#4123):** When a request carried user attribution, virtual-key usage accounting was silently skipped, causing VK budget and rate-limit tracking to be incomplete. Governance now tracks both the virtual-key and user scopes by default. Callers that intentionally want user-only accounting can opt in by setting the new `BifrostContextKeySkipVirtualKeyUsageTracking` (`bifrost-skip-virtual-key-usage-tracking`) context key. - **Wildcard allow-lists rejected models on catalog-opaque providers (#4124):** A `*` allowed-models entry was incorrectly blocking requests to providers whose model list cannot be enumerated by the catalog — custom providers without list-models support and keyless self-hosted deployments (vLLM, Ollama, SGL). A new shared `IsCatalogOpaqueProvider` helper is used to resolve wildcard allow-lists to allow-all for these providers. ## Type of change - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [x] Transports (HTTP) - [ ] Providers/Integrations - [x] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh # Core/Transports go version go test ./... ``` **Virtual key usage tracking:** Send a request with user attribution set and verify that both the virtual-key and user usage scopes are incremented. Then set `bifrost-skip-virtual-key-usage-tracking` on the context and confirm only the user scope is tracked. **Wildcard allow-lists:** Configure a virtual key with `allowed_models: ["*"]` against a custom or keyless self-hosted provider (vLLM/Ollama/SGL). Confirm requests are permitted rather than rejected. ## Breaking changes - [ ] Yes - [x] No ## Related issues - Closes #4123 - Closes #4124 ## Security considerations The new `BifrostContextKeySkipVirtualKeyUsageTracking` context key bypasses virtual-key usage accounting. Callers should ensure this flag is only set in controlled, intentional scenarios to avoid unintentionally circumventing budget and rate-limit enforcement on virtual keys. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
This is a hotfix release (v1.5.10) on top of v1.5.9 that addresses two targeted bugs in governance and provider model allow-listing. No new features, migrations, or behavioral opt-ins are introduced beyond the explicit opt-in flag described below. - **Virtual key usage dropped under user attribution (#4123):** When a request carried user attribution, virtual-key usage accounting was silently skipped, causing VK budget and rate-limit tracking to be incomplete. Governance now tracks both the virtual-key and user scopes by default. Callers that intentionally want user-only accounting can opt in by setting the new `BifrostContextKeySkipVirtualKeyUsageTracking` (`bifrost-skip-virtual-key-usage-tracking`) context key. - **Wildcard allow-lists rejected models on catalog-opaque providers (#4124):** A `*` allowed-models entry was incorrectly blocking requests to providers whose model list cannot be enumerated by the catalog — custom providers without list-models support and keyless self-hosted deployments (vLLM, Ollama, SGL). A new shared `IsCatalogOpaqueProvider` helper is used to resolve wildcard allow-lists to allow-all for these providers. - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI - [x] Core (Go) - [x] Transports (HTTP) - [ ] Providers/Integrations - [x] Plugins - [ ] UI (React) - [ ] Docs ```sh go version go test ./... ``` **Virtual key usage tracking:** Send a request with user attribution set and verify that both the virtual-key and user usage scopes are incremented. Then set `bifrost-skip-virtual-key-usage-tracking` on the context and confirm only the user scope is tracked. **Wildcard allow-lists:** Configure a virtual key with `allowed_models: ["*"]` against a custom or keyless self-hosted provider (vLLM/Ollama/SGL). Confirm requests are permitted rather than rejected. - [ ] Yes - [x] No - Closes #4123 - Closes #4124 The new `BifrostContextKeySkipVirtualKeyUsageTracking` context key bypasses virtual-key usage accounting. Callers should ensure this flag is only set in controlled, intentional scenarios to avoid unintentionally circumventing budget and rate-limit enforcement on virtual keys. - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
<Note> **Hotfix on [v1.5.9](https://docs.getbifrost.ai/changelogs/v1.5.9).** The key fix corrects wildcard (`*`) allowed-models handling: for providers whose models the catalog cannot enumerate, a wildcard now correctly allows any model instead of rejecting it. This affected keyless self-hosted providers (vLLM/Ollama/SGL) and custom providers without list-models support. </Note> ## 🐞 Fixed - **Virtual Key Usage Tracking Under User Attribution** - Usage is no longer silently dropped from virtual-key accounting whenever a user is attributed on a request. Governance now tracks both the virtual-key and user scopes by default; callers that deliberately want user-only accounting can opt in with the new `bifrost-skip-virtual-key-usage-tracking` context flag (#4123) - **Wildcard Allow-Lists for Catalog-Opaque Providers** - A wildcard (`*`) allowed-models list now correctly permits any model for providers whose models the catalog cannot enumerate - custom providers without list-models support, and keyless self-hosted vLLM/Ollama/SGL - instead of incorrectly rejecting them (#4124)

Summary
Virtual keys with a wildcard (
"*") allow-list on catalog-opaque providers (vLLM, Ollama, SGL, and other self-hosted or custom providers whose models are never indexed in the bundled model catalog) were being incorrectly dropped fromBifrostContextKeyAvailableProvidersand subsequently 403'd by the budget resolver. BecauseGetProvidersForModelreturns empty for these providers, the catalog cross-check treated every uncatalogued model as forbidden — dead-ending requests before they reached the backend. This fix introduces aisCatalogOpaqueProviderguard that short-circuits the catalog check when a wildcard is paired with a provider the catalog cannot enumerate, honoring the intent of"*"as allow-all.Changes
isCatalogOpaqueProviderinmain.goto identify providers whose model set the catalog cannot enumerate (custom providers with aCustomProviderConfig, or native providers with an empty catalog model list).loadBalanceProvider, whenAllowedModels.IsUnrestricted()and the provider is catalog-opaque,isProviderAllowedis set totruedirectly, bypassing the catalog cross-check that would otherwise exclude the provider.resolver.go(BudgetResolver.isModelAllowed), the same guard is applied so that a routed request is not 403'd after passing theAvailableProvidersgate.TestHTTPTransportPreHook_WildcardKeepsCatalogOpaqueProvider_VLLMto verify the end-to-end pre-hook behavior for a vLLM virtual key with a wildcard and an uncatalogued model.TestBudgetResolver_EvaluateRequest_WildcardAllowsCatalogOpaqueProviderto verify that the resolver allows wildcard + catalog-opaque (vLLM/uncatalogued model), while catalog-known providers (OpenAI) remain fully catalog-cross-checked under the same wildcard.Type of change
Affected areas
How to test
go test ./plugins/governance/...Expected: all tests pass, including the two new tests:
TestHTTPTransportPreHook_WildcardKeepsCatalogOpaqueProvider_VLLMTestBudgetResolver_EvaluateRequest_WildcardAllowsCatalogOpaqueProviderTo validate the fix manually, configure a virtual key with a vLLM provider and
allowed_models: ["*"], then send a chat completion request with a self-hosted model name. The request should route successfully instead of returning a 403 or empty provider error.Screenshots/Recordings
N/A
Breaking changes
Related issues
Closes #4122
Closes #3282
Security considerations
The wildcard bypass is scoped exclusively to providers the catalog has no knowledge of. For all catalog-known providers (e.g., OpenAI, Anthropic), the existing catalog cross-check is preserved, so there is no regression in model-level access control for first-party providers.
Checklist
docs/contributing/README.mdand followed the guidelinesSummary by CodeRabbit
Tests
Improvements