toeverything/AFFiNE · error · SubscriptionNotExists
subscription_not_exists
subscription_not_exists
Error message
You didn't subscribe to the ${plan} plan. What it means
Thrown by SubscriptionService.cancelSubscription when manager.getActiveSubscription(identity) returns null, i.e. there is no active subscription for the given identity (user or workspace) and plan. Cancel is only valid against an existing active subscription.
Solutions
- Re-query the current subscription list (e.g. currentUser { subscriptions } or the workspace equivalent) and only offer Cancel for plans that are actually active.
- Verify the identity matches the subscription: same userId (or workspaceId) and plan that getActiveSubscription searches for.
- Treat this code in async flows as 'already gone': skip retry and refresh local state from the server.
Example fix
// before
setBusy(true);
await svc.cancelSubscription({ userId, plan });
// after
const subs = await listSubscriptions();
const active = subs.find((s) => s.plan === plan && s.status === 'active');
if (!active) return refresh();
await svc.cancelSubscription({ userId, plan }); Defensive patterns
Strategy: validation
Validate before calling
const subs = await listSubscriptions();
const active = subs.some((s) => s.plan === identity.plan && s.status === 'active');
if (!active) throw new Error('No active subscription to cancel');
await svc.cancelSubscription(identity, idempotencyKey); Type guard
interface SubLike { plan: string; status: string; }
function hasActivePlan(subs: SubLike[], plan: string): boolean {
return subs.some((s) => s.plan === plan && s.status === 'active');
} Try / catch
catch (e) { if (gqlErrorCode(e) === 'subscription_not_exists') { await refreshSubscriptions(); notify('You are not subscribed to this plan.'); return; } throw e; } Prevention
- Derive cancel/resume buttons from a fresh server subscription query, not cache.
- Send an Idempotency-Key header with cancel/resume calls.
- Treat subscription_not_exists as authoritative state, never retry it.
When it happens
Trigger: Calling cancelSubscription({ userId, plan: 'pro' }) when the user is on Free or already fully expired; canceling a team plan with a workspaceId that has no subscription; plan/recurring mismatch with what was actually purchased.
Common situations: Stale UI showing a Cancel button after the subscription lapsed or was removed by webhook; user canceled earlier and a sync race re-showed active state; wrong workspace selected in a multi-workspace client.
Related errors
- cant_update_onetime_payment_subscription
- subscription_has_been_canceled
- managed_by_app_store_or_play
- subscription_expired
- subscription_has_not_been_canceled
AI-assisted analysis of toeverything/AFFiNE@d897bb3d84 (2026-08-18).
Data as JSON: /api/errors/e7328dbd1d028207.
Report an issue: GitHub.
Appendix: source
Thrown at packages/backend/server/src/plugins/payment/service.ts:193
idempotencyKey?: string
) {
return this.mutate(identity, 'cancel', idempotencyKey);
}
async resumeSubscription(
identity: SubscriptionIdentity,
idempotencyKey?: string
) {
return this.mutate(identity, 'resume', idempotencyKey);
}
async updateSubscriptionRecurring(
identity: SubscriptionIdentity,
recurring: SubscriptionRecurring,
idempotencyKey?: string
) {
const target = subscriptionTarget(identity);
const subscription = await this.command<Subscription>({
action: 'update_recurring',
actorUserId: target.actor,
targetType: target.type,
targetId: target.id,
plan: identity.plan,
recurring,
intentId: idempotencyKey ?? randomUUID(),
});
return normalizeSubscription(subscription);
}
async updateSubscriptionQuantity(
identity: SubscriptionIdentity,
quantity: number
) {
const target = subscriptionTarget(identity);
await this.command({
action: 'update_quantity',View on GitHub (pinned to d897bb3d84)