{"record":{"id":"c4868c1dd187ea17","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-fetch-rate-limit","errorCode":null,"errorMessage":"Failed to fetch rate limit","messagePattern":"Failed to fetch rate limit","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/useRateLimitManager.ts","lineNumber":52,"sourceCode":"  const [selectedUser, setSelectedUser] = useState<UserOption | null>(null);\n  const [rateLimitData, setRateLimitData] =\n    useState<UserRateLimitResponse | null>(null);\n\n  const tierMultipliers = rateLimitData?.tier_multipliers;\n\n  async function handleDirectLookup(trimmed: string) {\n    setIsSearching(true);\n    setSearchResults([]);\n    setSelectedUser(null);\n    setRateLimitData(null);\n\n    try {\n      const params = looksLikeEmail(trimmed)\n        ? { email: trimmed }\n        : { user_id: trimmed };\n      const response = await getV2GetUserRateLimit(params);\n      if (response.status !== 200) {\n        throw new Error(\"Failed to fetch rate limit\");\n      }\n      setRateLimitData(response.data);\n      setSelectedUser({\n        user_id: response.data.user_id,\n        user_email: response.data.user_email ?? response.data.user_id,\n      });\n    } catch (error) {\n      console.error(\"Error fetching rate limit:\", error);\n      const hint = looksLikeEmail(trimmed)\n        ? \"No user found with that email address.\"\n        : \"Check the user ID and try again.\";\n      toast({\n        title: \"Error\",\n        description: `Failed to fetch rate limits. ${hint}`,\n        variant: \"destructive\",\n      });\n      setRateLimitData(null);\n    } finally {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/useRateLimitManager.ts#L34-L70","documentation":"Raised by reject_transfer when the caller's active org is neither the source nor the target organization of the transfer. Only parties to the transfer may reject it; unrelated orgs (even authenticated ones) are refused.","triggerScenarios":"Calling reject with an active org_id that differs from both tr.sourceOrganizationId and tr.targetOrganizationId — e.g. a multi-org user acting with the wrong org selected.","commonSituations":"Stale active-org selection in the UI; user switched orgs but the session still carries the old org; testing with an account that has no relation to the transfer.","solutions":["Preflight-check the active org against the transfer's two org ids and prompt a switch.","Keep the active-org context fresh on every transfers API call from the frontend.","Include the party org ids in the 4xx response detail to make the mismatch obvious."],"exampleFix":"# before\nawait reject_transfer(tid, user_id, org_id)\n\n# after\ntr = await get_transfer(tid)\nif org_id not in (tr.source_org_id, tr.target_org_id):\n    raise PermissionError(\"Active org is not a party; switch org first\")\nawait reject_transfer(tid, user_id, org_id)","handlingStrategy":"type-guard","validationCode":"tr = await get_transfer(transfer_id)\nif org_id not in (tr.source_org_id, tr.target_org_id):\n    raise PermissionError(\"Active org is not a party; switch org\")","typeGuard":"def org_is_party(tr: TransferResponse, org_id: str) -> bool:\n    return org_id in (tr.source_org_id, tr.target_org_id)","tryCatchPattern":"try:\n    await reject_transfer(tid, user_id, org_id)\nexcept ValueError as e:\n    if \"not a party\" in str(e):\n        prompt_org_switch(tr)\n    else:\n        raise","preventionTips":["Keep active-org selection in sync with the request header","Check party membership before exposing reject in the UI"],"tags":["transfers","authorization","multi-org"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}