Skip to content
Open
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 backend/internal/service/api_key_auth_cache_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/dgraph-io/ristretto"
)

const apiKeyAuthSnapshotVersion = 9 // v9: added API Key name for audit logs
const apiKeyAuthSnapshotVersion = 10 // v10: invalidate legacy auth snapshots missing image-generation fields

type apiKeyAuthCacheConfig struct {
l1Size int
Expand Down
7 changes: 7 additions & 0 deletions backend/internal/service/api_key_service_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ func TestAPIKeyService_SnapshotRoundTrip_PreservesMessagesDispatchModelConfig(t
Status: StatusActive,
SubscriptionType: SubscriptionTypeStandard,
RateMultiplier: 1,
AllowImageGeneration: true,
ImageRateIndependent: true,
ImageRateMultiplier: 1.75,
AllowMessagesDispatch: true,
DefaultMappedModel: "gpt-5.4",
MessagesDispatchModelConfig: OpenAIMessagesDispatchModelConfig{
Expand All @@ -270,6 +273,9 @@ func TestAPIKeyService_SnapshotRoundTrip_PreservesMessagesDispatchModelConfig(t
require.NotNil(t, roundTrip)
require.Equal(t, apiKey.Name, roundTrip.Name)
require.NotNil(t, roundTrip.Group)
require.True(t, roundTrip.Group.AllowImageGeneration)
require.True(t, roundTrip.Group.ImageRateIndependent)
require.Equal(t, 1.75, roundTrip.Group.ImageRateMultiplier)
require.Equal(t, apiKey.Group.MessagesDispatchModelConfig, roundTrip.Group.MessagesDispatchModelConfig)
}

Expand Down Expand Up @@ -320,6 +326,7 @@ func TestAPIKeyService_GetByKey_IgnoresLegacyAuthCacheSnapshotWithoutMessagesDis
cache.getAuthCache = func(ctx context.Context, key string) (*APIKeyAuthCacheEntry, error) {
return &APIKeyAuthCacheEntry{
Snapshot: &APIKeyAuthSnapshot{
Version: apiKeyAuthSnapshotVersion - 1,
APIKeyID: 1,
UserID: 2,
GroupID: &groupID,
Expand Down
Loading