Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion transports/bifrost-http/handlers/list_models_vk.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (h *CompletionHandler) applyListModelsVirtualKeyProviderFilter(ctx *fasthtt
SendError(ctx, fasthttp.StatusInternalServerError, fmt.Sprintf("Failed to resolve virtual key: %v", err))
return false
}
if vk == nil || !vk.IsActive {
if vk == nil || vk.IsActive == nil || !*vk.IsActive {
return true
}
Comment on lines +42 to 44

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 nil IsActive incorrectly bypasses provider filter

TableVirtualKey.IsActive is documented as "Nil means true (DB default); false means inactive" (see virtualkey.go:213 and the IsActiveValue() helper at line 247). When vk.IsActive == nil the VK is semantically active, but the new vk.IsActive == nil clause causes an early return true, silently skipping the ProviderConfigs filter. Any VK that was inserted with the DB default (nil IsActive) will expose all configured providers instead of only the ones in its ProviderConfigs.

The existing IsActiveValue() method already encodes the correct nil-as-true semantics. The condition should be if vk == nil || !vk.IsActiveValue() instead.


Expand Down
4 changes: 2 additions & 2 deletions transports/bifrost-http/handlers/list_models_vk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestApplyListModelsVirtualKeyProviderFilterSetsActiveVKProviders(t *testing
config: &lib.Config{
ConfigStore: &mockListModelsVKConfigStore{vk: &configstoreTables.TableVirtualKey{
Value: "sk-bf-active",
IsActive: true,
IsActive: new(true),
ProviderConfigs: []configstoreTables.TableVirtualKeyProviderConfig{
{Provider: "openai"},
{Provider: " anthropic "},
Expand Down Expand Up @@ -125,7 +125,7 @@ func TestApplyListModelsVirtualKeyProviderFilterSkipsInactiveVK(t *testing.T) {
config: &lib.Config{
ConfigStore: &mockListModelsVKConfigStore{vk: &configstoreTables.TableVirtualKey{
Value: "sk-bf-inactive",
IsActive: false,
IsActive: new(false),
ProviderConfigs: []configstoreTables.TableVirtualKeyProviderConfig{
{Provider: "openai"},
},
Expand Down
Loading