Significant-Gravitas/AutoGPT · error · HTTPException

No payment method on file. The plan was not changed; please

Error message

No payment method on file. The plan was not changed; please add a payment method and try again.

What it means

HTTP 402 raised when the subscription upgrade fails with stripe.InvalidRequestError matching the no-payment-method shapes: e.param in {payment_method, invoice_settings.default_payment_method}, or the message containing 'no attached payment source'/'default payment method'/'no payment method'. With error_if_incomplete, a modify with no default payment method presents as InvalidRequestError rather than CardError, so it is matched by param/substring and mapped to 402.

Source

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

        # param, sometimes without (the raw "no attached payment source"
        # message has empty param). Map it to 402 either way.
        if e.code in {"resource_missing", "missing"} and (
            e.param
            in {
                "default_payment_method",
                "payment_method",
                "invoice_settings.default_payment_method",
            }
            or "no attached payment source" in msg_lower
            or "default payment method" in msg_lower
            or "no payment method" in msg_lower
        ):
            logger.warning(
                "No payment method on subscription upgrade for user %s: %s",
                user_id,
                e,
            )
            raise HTTPException(
                status_code=402,
                detail=(
                    "No payment method on file. The plan was not changed;"
                    " please add a payment method and try again."
                ),
            )
        # Stripe rejects schedule modify when phases mix currencies, e.g. the
        # active sub was checked out in GBP but the target tier's Price is
        # USD-only. e.param is "currency" on the schedule API but may be
        # "phases" or absent on older error shapes — substring fallback keeps
        # the 422 firing instead of dropping to the generic 502.
        if e.param == "currency" or "currency" in msg_lower:
            logger.warning(
                "Currency mismatch on tier change for user %s: %s", user_id, e
            )
            raise HTTPException(
                status_code=422,
                detail=(

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Add a payment method in the billing portal first, then retry the upgrade
  2. Verify in Stripe that invoice_settings.default_payment_method is set on the customer
  3. As an operator: enforce card collection before granting paid tiers
Defensive patterns

Strategy: validation

Validate before calling

const status = await api.getSubscriptionStatus();
if (req.tier !== "BASIC" && !status.hasPaymentMethod) await redirectToAddPaymentMethod();

Try / catch

try { await api.setSubscription(req); }
catch (e) {
  if (e.status === 402 && /No payment method on file/.test(e.detail)) openAddCardFlow();
  else throw e;
}

Prevention

When it happens

Trigger: Upgrading from an admin-granted paid tier (or a subscription created without a card) where the Stripe customer has no default payment method; the auto-charge on modify cannot find a source to charge.

Common situations: Admin comped a tier and the user never added a card; a subscription started with a trial requiring no card; payment method was detached in the Stripe dashboard; legacy customers predating mandatory cards.

Related errors


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