fix(quota): orphan pool (no valid connection) must not contribute its slug to key scope

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).
This commit is contained in:
diegosouzapw
2026-05-31 01:36:53 -03:00
parent 009c928d0a
commit d07d3dcdaf

View File

@@ -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 {