{"record":{"id":"db911f64753f8d23","repo":"Significant-Gravitas/AutoGPT","slug":"unable-to-cancel-the-pending-subscription-change-r","errorCode":null,"errorMessage":"Unable to cancel the pending subscription change right now. Please try again or contact support.","messagePattern":"Unable to cancel the pending subscription change right now\\. Please try again or contact support\\.","errorType":"http","errorClass":"HTTPException","httpStatus":502,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/v1.py","lineNumber":1122,"sourceCode":"    current_tier = user.subscription_tier or SubscriptionTier.NO_TIER\n    current_cycle = await get_user_billing_cycle(user_id) or \"monthly\"\n    has_active_stripe_subscription = (\n        await get_active_subscription_period_end(user_id) is not None\n    )\n    if (\n        current_tier == tier\n        and current_cycle == request.billing_cycle\n        and has_active_stripe_subscription\n    ):\n        try:\n            await release_pending_subscription_schedule(user_id)\n        except stripe.StripeError as e:\n            logger.exception(\n                \"Stripe error releasing pending subscription change for user %s: %s\",\n                user_id,\n                e,\n            )\n            raise HTTPException(\n                status_code=502,\n                detail=(\n                    \"Unable to cancel the pending subscription change right now. \"\n                    \"Please try again or contact support.\"\n                ),\n            )\n        return await get_subscription_status(user_id)\n\n    payment_enabled = await is_feature_enabled(\n        Flag.ENABLE_PLATFORM_PAYMENT, user_id, default=False\n    )\n\n    target_price_id = await get_subscription_price_id(tier, request.billing_cycle)\n\n    # Cancel: target NO_TIER. Schedule Stripe cancellation at period end;\n    # cancel_at_period_end=True lets the webhook flip the DB tier. No active\n    # sub (admin-granted or never-paid) or payment disabled → DB flip.\n    # NO_TIER is never priceable, so this branch always fires for cancel","sourceCodeStart":1104,"sourceCodeEnd":1140,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/v1.py#L1104-L1140","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry the request after a short wait - transient Stripe errors usually clear","Check the Stripe dashboard for the subscription's schedule state; release/cancel it manually if it is stuck","Verify STRIPE API keys and webhook config on the backend; the logger.exception output shows the exact Stripe error","If it persists, contact support with the user ID from the log line"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await api.setSubscription(sameTierAndCycle); }\ncatch (e) {\n  if (e.status === 502) { await backoff(); retryOnce(); } else throw e;\n}","preventionTips":["Surface the support contact on 502 in billing UI","Verify Stripe schedule state in the dashboard when retries keep failing"],"tags":["stripe","subscription","http-502","upstream"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}