From 7238871a3af1b38612cc3c62bdffe932ceb14b89 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 10:17:28 +0000 Subject: [PATCH] refactor(scope): use groups helper for quota counting Co-Authored-By: Virgil --- scope.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scope.go b/scope.go index 36e75b7..524f038 100644 --- a/scope.go +++ b/scope.go @@ -751,14 +751,12 @@ func (scopedStore *ScopedStore) checkQuota(operation, group, key string) error { return core.E(operation, "quota check", err) } if existingGroupCount == 0 { - // This group is new — check if adding it would exceed the group limit. - knownGroupCount := 0 - for _, iterationErr := range scopedStore.backingStore.GroupsSeq(namespacePrefix) { - if iterationErr != nil { - return core.E(operation, "quota check", iterationErr) - } - knownGroupCount++ + // This group is new, so count existing namespace groups with the public helper. + groupNames, err := scopedStore.backingStore.Groups(namespacePrefix) + if err != nil { + return core.E(operation, "quota check", err) } + knownGroupCount := len(groupNames) if knownGroupCount >= scopedStore.MaxGroups { return core.E(operation, core.Sprintf("group limit (%d)", scopedStore.MaxGroups), QuotaExceededError) } -- 2.45.3