Significant-Gravitas/AutoGPT · error · HTTPException

Unable to cancel the pending subscription change right now.

Error message

Unable to cancel the pending subscription change right now. Please try again or contact support.

What it means

HTTP 502 from POST /credits/subscription when releasing a pending Stripe subscription schedule fails with a stripe.StripeError. Re-POSTing your current tier + billing cycle is interpreted as 'cancel my pending change', which calls release_pending_subscription_schedule; if Stripe errors (network, invalid schedule state, API issue), the route surfaces 502 and logs the exception.

Source

Thrown at autogpt_platform/backend/backend/api/features/v1.py:1122

    current_tier = user.subscription_tier or SubscriptionTier.NO_TIER
    current_cycle = await get_user_billing_cycle(user_id) or "monthly"
    has_active_stripe_subscription = (
        await get_active_subscription_period_end(user_id) is not None
    )
    if (
        current_tier == tier
        and current_cycle == request.billing_cycle
        and has_active_stripe_subscription
    ):
        try:
            await release_pending_subscription_schedule(user_id)
        except stripe.StripeError as e:
            logger.exception(
                "Stripe error releasing pending subscription change for user %s: %s",
                user_id,
                e,
            )
            raise HTTPException(
                status_code=502,
                detail=(
                    "Unable to cancel the pending subscription change right now. "
                    "Please try again or contact support."
                ),
            )
        return await get_subscription_status(user_id)

    payment_enabled = await is_feature_enabled(
        Flag.ENABLE_PLATFORM_PAYMENT, user_id, default=False
    )

    target_price_id = await get_subscription_price_id(tier, request.billing_cycle)

    # Cancel: target NO_TIER. Schedule Stripe cancellation at period end;
    # cancel_at_period_end=True lets the webhook flip the DB tier. No active
    # sub (admin-granted or never-paid) or payment disabled → DB flip.
    # NO_TIER is never priceable, so this branch always fires for cancel

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Retry the request after a short wait - transient Stripe errors usually clear
  2. Check the Stripe dashboard for the subscription's schedule state; release/cancel it manually if it is stuck
  3. Verify STRIPE API keys and webhook config on the backend; the logger.exception output shows the exact Stripe error
  4. If it persists, contact support with the user ID from the log line
Defensive patterns

Strategy: retry

Try / catch

try { await api.setSubscription(sameTierAndCycle); }
catch (e) {
  if (e.status === 502) { await backoff(); retryOnce(); } else throw e;
}

Prevention

When it happens

Trigger: User with an active Stripe subscription and a pending scheduled change submits a request whose tier and billing_cycle both equal their current ones; Stripe's schedule release call then fails.

Common situations: Stripe API connectivity issues; the subscription schedule was already released or modified out-of-band (deleted in the Stripe dashboard) so the release call 404s; Stripe key misconfiguration in the environment; rate limiting.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/db911f64753f8d23. Report an issue: GitHub.