fix(modelcatalog): wildcard allow-list permits any model on custom providers#4535
fix(modelcatalog): wildcard allow-list permits any model on custom providers#4535mickgvirtu wants to merge 1 commit into
Conversation
📝 WalkthroughSummary by CodeRabbitRelease Notes
Walkthrough
ChangesCustom provider wildcard allow-list behavior and test coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 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)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
framework/modelcatalog/models_test.go (1)
45-55: ⚡ Quick winAdd the positive native wildcard case.
This only proves wildcard denies unserved native models. Since the PR preserves native catalog cross-checking, add a seeded native-provider model case that must return
true; otherwise, a regression that denies all native wildcard requests would still pass.🤖 Prompt for 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. In `@framework/modelcatalog/models_test.go` around lines 45 - 55, The test TestIsModelAllowedForProvider_WildcardNativeProviderUnserved only validates the negative case where a wildcard denies an unserved model. Add a complementary positive test case that seeds the catalog with a model served by a native provider (such as OpenAI) and verifies that IsModelAllowedForProvider returns true when called with a wildcard for that same provider and model. This ensures the code correctly allows wildcards for native providers when models are properly served, preventing regressions where all native wildcard requests might be incorrectly denied.
🤖 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.
Nitpick comments:
In `@framework/modelcatalog/models_test.go`:
- Around line 45-55: The test
TestIsModelAllowedForProvider_WildcardNativeProviderUnserved only validates the
negative case where a wildcard denies an unserved model. Add a complementary
positive test case that seeds the catalog with a model served by a native
provider (such as OpenAI) and verifies that IsModelAllowedForProvider returns
true when called with a wildcard for that same provider and model. This ensures
the code correctly allows wildcards for native providers when models are
properly served, preventing regressions where all native wildcard requests might
be incorrectly denied.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 794c8382-74f6-4e2b-8a5e-4548a3c66474
📒 Files selected for processing (2)
framework/modelcatalog/models.goframework/modelcatalog/models_test.go
IsModelAllowedForProvider: a ["*"] (All models) virtual-key allow-list permits any model on a custom (OpenAI-compatible) provider, whose backend the catalog can't enumerate. Native providers stay catalog-cross-checked so a wildcard can't spray a model to a provider that doesn't serve it. Fixes spurious model_blocked 403s on internal models (e.g. glm) on custom providers. Adds unit tests for the custom/native asymmetry, empty deny-by-default, and explicit matching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ef70510 to
3e052a2
Compare
|
Thanks — both addressed:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/architecture/framework/model-catalog.mdx (1)
292-298:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFix example call signature to match implementation
At Line 294, the docs call
IsModelAllowedForProviderwith 3 args, but the current method takes 4 args (providerConfigbeforeallowedModels). This example is currently copy/paste incorrect.Suggested docs patch
isAllowed := modelCatalog.IsModelAllowedForProvider( schemas.OpenRouter, "gpt-4o", - schemas.WhiteList{"*"}, // wildcard = check catalog + nil, // providerConfig (nil for native provider example) + schemas.WhiteList{"*"}, // wildcard = check catalog )As per coding guidelines, docs under
docs/**should maintain parity with code behavior/contracts.🤖 Prompt for 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. In `@docs/architecture/framework/model-catalog.mdx` around lines 292 - 298, The example call to IsModelAllowedForProvider in the documentation is incorrect - it currently passes 3 arguments but the actual method signature requires 4 arguments with providerConfig appearing before allowedModels. Update the example code snippet to include the missing providerConfig argument and reorder the parameters to match the actual method implementation signature for IsModelAllowedForProvider.Source: Coding guidelines
🤖 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.
Outside diff comments:
In `@docs/architecture/framework/model-catalog.mdx`:
- Around line 292-298: The example call to IsModelAllowedForProvider in the
documentation is incorrect - it currently passes 3 arguments but the actual
method signature requires 4 arguments with providerConfig appearing before
allowedModels. Update the example code snippet to include the missing
providerConfig argument and reorder the parameters to match the actual method
implementation signature for IsModelAllowedForProvider.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f7156ed-9cbc-4e2b-9552-fc299a258d9e
📒 Files selected for processing (3)
docs/architecture/framework/model-catalog.mdxframework/modelcatalog/models.goframework/modelcatalog/models_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- framework/modelcatalog/models.go
Summary
With a virtual-key allow-list of
["*"]("All models"),IsModelAllowedForProviderstill cross-checks the model against the catalog viaGetProvidersForModel. For a custom (OpenAI-compatible) provider the catalog can't enumerate the backend's models, so legitimate models the operator pointed the provider at are wrongly denied withmodel_blocked.Changes
["*"]now means "all models on this provider" (returns true). Native providers stay catalog-cross-checked, so a wildcard can't spray a model to a provider that doesn't serve it.BlacklistedModels.IsBlocked, which wins over the allow-list), so a wildcard does not bypass explicit denials.Type of change
Affected areas
How to test
go test ./framework/modelcatalog/New
models_test.gocovers: wildcard+custom+uncatalogued ⇒ allow; wildcard+native+unserved ⇒ deny; empty ⇒ deny; explicit match.