From d07d3dcdaf3a2b8257dacd20ce66f8f88acdcf07 Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Sun, 31 May 2026 01:36:53 -0300 Subject: [PATCH] fix(quota): orphan pool (no valid connection) must not contribute its slug to key scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit D2 moved poolSlug collection outside the connection loop, so a pool whose only connection was deleted still leaked its slug into resolveQuotaKeyScope — that slug has no quotaShared-* models behind it. Gate the slug on >=1 valid member connection (restores Phase-A2 behavior for multi-connection pools). --- src/lib/quota/quotaKey.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/quota/quotaKey.ts b/src/lib/quota/quotaKey.ts index 05520e7bbe..e493e64f60 100644 --- a/src/lib/quota/quotaKey.ts +++ b/src/lib/quota/quotaKey.ts @@ -79,6 +79,7 @@ export async function resolveQuotaKeyScope( ? pool.connectionIds : [pool.connectionId]; + let anyValidConnection = false; for (const connId of connIds) { const connection = await getProviderConnectionById(connId); if (!connection) continue; // missing connection contributes nothing; don't abort @@ -88,9 +89,13 @@ export async function resolveQuotaKeyScope( connectionIdSet.add(connId); providerSet.add(provider); + anyValidConnection = true; } - poolSlugSet.add(quotaPoolSlug(pool.name)); + // Only expose the pool's slug when it has at least one usable connection — + // an orphan pool (all connections deleted) has no quotaShared-* models, so + // its slug must not leak into the key's scope. + if (anyValidConnection) poolSlugSet.add(quotaPoolSlug(pool.name)); } return {