{"record":{"id":"4b2fa37321354794","repo":"Significant-Gravitas/AutoGPT","slug":"rate-limit-reset-is-not-available-credit-system-i","errorCode":null,"errorMessage":"Rate limit reset is not available (credit system is disabled).","messagePattern":"Rate limit reset is not available \\(credit system is disabled\\)\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/chat/routes.py","lineNumber":1034,"sourceCode":"async def reset_copilot_usage(\n    user_id: Annotated[str, Security(auth.get_user_id)],\n) -> RateLimitResetResponse:\n    \"\"\"Reset the daily CoPilot rate limit by spending credits.\n\n    Allows users who have hit their daily cost limit to spend credits\n    to reset their daily usage counter and continue working.\n    Returns 400 if the feature is disabled or the user is not over the limit.\n    Returns 402 if the user has insufficient credits.\n    \"\"\"\n    cost = config.rate_limit_reset_cost\n    if cost <= 0:\n        raise HTTPException(\n            status_code=400,\n            detail=\"Rate limit reset is not available.\",\n        )\n\n    if not settings.config.enable_credit:\n        raise HTTPException(\n            status_code=400,\n            detail=\"Rate limit reset is not available (credit system is disabled).\",\n        )\n\n    daily_limit, weekly_limit, tier = await get_global_rate_limits(\n        user_id,\n        config.daily_cost_limit_microdollars,\n        config.weekly_cost_limit_microdollars,\n    )\n\n    if daily_limit <= 0:\n        raise HTTPException(\n            status_code=400,\n            detail=\"No daily limit is configured — nothing to reset.\",\n        )\n\n    # Check max daily resets.  get_daily_reset_count returns None when Redis\n    # is unavailable; reject the reset in that case to prevent unlimited","sourceCodeStart":1016,"sourceCodeEnd":1052,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/chat/routes.py#L1016-L1052","documentation":"HTTP 400 from POST /usage/reset (routes.py:1034). Even with a positive reset cost configured, the endpoint refuses to run when the platform-wide credit system is off (`settings.config.enable_credit` is False, defined in backend/util/settings.py:196). Spending credits is the whole mechanism of the reset, so a disabled credit system makes the endpoint meaningless and it fails fast with 400.","triggerScenarios":"POST to the usage-reset endpoint on a deployment where ENABLE_CREDIT=false in backend .env / settings. Reproduced in tests via mocker.patch.object(chat_routes.settings.config, \"enable_credit\", False) (routes_test.py:2600).","commonSituations":"Self-hosted or marketplace-style deployment that intentionally runs without the credit/billing system; env drift where .env overrides enable_credit to false but the copilot reset cost is still configured; staging environment copied from a no-billing template.","solutions":["Enable the credit system: set enable_credit=true (ENABLE_CREDIT) in backend settings/.env and restart.","If credits are intentionally disabled, also set rate_limit_reset_cost=0 so the endpoint fails at the first guard with the generic message, and remove the reset affordance from the UI.","Client-side: treat this 400 as permanent configuration, not retryable."],"exampleFix":"# before\nENABLE_CREDIT=false   # backend/.env -> every /usage/reset call returns 400\n\n# after\nENABLE_CREDIT=true","handlingStrategy":"validation","validationCode":"// only offer paid reset when the platform runs the credit system\nif (!platformConfig.enable_credit || usage.rate_limit_reset_cost <= 0) {\n  hideResetUI();\n}","typeGuard":null,"tryCatchPattern":"try { await post('/chat/usage/reset'); } catch (e) { if (e.status === 400 && /credit system is disabled/.test(e.detail)) { hideResetUI(); return; } throw e; }","preventionTips":["Expose enable_credit (or a derived 'paidResetAvailable' boolean) to the client","Align config: enable_credit=false should imply rate_limit_reset_cost=0","Do not retry a 400 caused by deployment configuration"],"tags":["http","config","credits","billing","fastapi"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}