{"record":{"id":"b31cb4e6b1bd8991","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-reset-usage","errorCode":null,"errorMessage":"Failed to reset usage","messagePattern":"Failed to reset usage","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/useRateLimitManager.ts","lineNumber":160,"sourceCode":"    }\n  }\n\n  async function handleSelectUser(user: UserOption) {\n    setSelectedUser(user);\n    setRateLimitData(null);\n    await fetchRateLimit(user.user_id);\n  }\n\n  async function handleReset(resetWeekly: boolean) {\n    if (!rateLimitData) return;\n\n    try {\n      const response = await postV2ResetUserRateLimitUsage({\n        user_id: rateLimitData.user_id,\n        reset_weekly: resetWeekly,\n      });\n      if (response.status !== 200) {\n        throw new Error(\"Failed to reset usage\");\n      }\n      setRateLimitData(response.data);\n      toast({\n        title: \"Success\",\n        description: resetWeekly\n          ? \"Daily and weekly usage reset to zero.\"\n          : \"Daily usage reset to zero.\",\n      });\n    } catch (error) {\n      console.error(\"Error resetting rate limit:\", error);\n      toast({\n        title: \"Error\",\n        description: \"Failed to reset rate limit usage.\",\n        variant: \"destructive\",\n      });\n    }\n  }\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/useRateLimitManager.ts#L142-L178","documentation":"Raised by execute_transfer when either sourceApprovedByUserId or targetApprovedByUserId is null. Execution moves the resource between orgs and requires explicit approval from both sides; a single-sided approval leaves the transfer in SOURCE_APPROVED/TARGET_APPROVED state, not executable.","triggerScenarios":"Calling execute after only one org approved (status is still SOURCE_APPROVED or TARGET_APPROVED). E.g. the source org approves and immediately tries to execute before the target org has acted.","commonSituations":"Misunderstanding that one approval suffices; UI showing an execute button as soon as the current user approved; automation firing execute on status change without checking both approval fields.","solutions":["Gate the execute action on both sourceApprovedByUserId and targetApprovedByUserId being set (equivalently, on status being fully approved).","Poll or subscribe to the transfer and only enable execute when both approvals exist.","Read the status field: only attempt execute once the transfer leaves the single-sided approved states."],"exampleFix":"# before\nawait execute_transfer(tid, user_id, org_id)\n\n# after\ntr = await get_transfer(tid)\nif not (tr.source_approved_by_user_id and tr.target_approved_by_user_id):\n    raise RuntimeError(\"Waiting for the second org's approval\")\nawait execute_transfer(tid, user_id, org_id)","handlingStrategy":"validation","validationCode":"tr = await get_transfer(transfer_id)\nif not (tr.source_approved_by_user_id and tr.target_approved_by_user_id):\n    wait_for_second_approval()  # do not execute yet","typeGuard":"def fully_approved(tr: TransferResponse) -> bool:\n    return tr.source_approved_by_user_id is not None and tr.target_approved_by_user_id is not None","tryCatchPattern":"try:\n    await execute_transfer(tid, user_id, org_id)\nexcept ValueError as e:\n    if \"approval from both\" in str(e):\n        notify_missing_side(tr)\n    else:\n        raise","preventionTips":["Enable execute only when both approval fields are set","Poll or subscribe to the transfer between approvals"],"tags":["transfers","approval","state-machine"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}