mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix(billing): stop a zero seat limit turning free orgs read-only
`getServiceLimit('members')` returned `plan.addons.seats.limit ?? 1`. The
Appwrite starter plan's seats addon omits `limit`, and the API serializes
the missing value as `0` — which is not nullish, so the `?? 1` fallback
never applied and the limit came back as `0`.
`checkForUsageLimit` then read that as "no members allowed":
membersOverflow = Math.max(0, organization.total - 0) // always >= 1
so every free-plan organization was flipped to read-only, which silently
disables project creation, member invites and the other write actions
gated on `readOnly`. The explanatory banner never showed either, because
`limitReached.svelte` is gated on `!billingPlanDetails.usage` and the
starter plan's `usage` serializes to a truthy object — leaving a
greyed-out "Create project" button with no reason given.
Normalise a zero limit to `Infinity` in `getServiceLimit` so every caller
agrees, and only treat a real, positive cap as exceedable so a bad limit
can't take an organization read-only again. The UI call sites already
worked around this with `getServiceLimit('members', ...) || Infinity`;
`checkForUsageLimit` was the only consumer that did not.
Plans that set an explicit seat limit (the Imagine plans use 1) are
unaffected, as are Pro, Scale and Education, which declare no seats addon
and already returned `Infinity`.
This commit is contained in:
1 parent
a41838a86d
commit
2f91099c17
1 file changed
+9
-2
@@ -277,7 +277,10 @@ export function getServiceLimit(
|
||||
|
||||
if (serviceId === 'members') {
|
||||
if (!plan?.addons?.seats) return Infinity;
|
||||
return plan.addons.seats?.limit ?? 1;
|
||||
// Plans that don't cap seats omit `limit` in the plan config, and the API
|
||||
// serializes the missing value as `0`. That means "no seat cap", not
|
||||
// "no members allowed" — an organization always has at least one member.
|
||||
return plan.addons.seats?.limit || Infinity;
|
||||
}
|
||||
|
||||
if (serviceId === 'projects') {
|
||||
@@ -474,7 +477,11 @@ export async function checkForUsageLimit(organization: Models.Organization) {
|
||||
|
||||
const members = organization.total;
|
||||
const memberLimit = getServiceLimit('members');
|
||||
const membersOverflow = memberLimit === Infinity ? 0 : Math.max(0, members - memberLimit);
|
||||
// Only a real, positive cap can be exceeded. Without this guard an unknown or
|
||||
// zero limit turns every organization read-only, which silently disables
|
||||
// project creation, member invites and every other write action.
|
||||
const membersOverflow =
|
||||
Number.isFinite(memberLimit) && memberLimit > 0 ? Math.max(0, members - memberLimit) : 0;
|
||||
|
||||
if (resources.some((r) => r.value >= 100) || membersOverflow > 0) {
|
||||
readOnly.set(true);
|
||||
|
||||
Reference in new issue
Block a user