Significant-Gravitas/AutoGPT · error · Error

Failed to fetch rate limit

Error message

Failed to fetch rate limit

What it means

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.

Source

Thrown at autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/useRateLimitManager.ts:52

  const [selectedUser, setSelectedUser] = useState<UserOption | null>(null);
  const [rateLimitData, setRateLimitData] =
    useState<UserRateLimitResponse | null>(null);

  const tierMultipliers = rateLimitData?.tier_multipliers;

  async function handleDirectLookup(trimmed: string) {
    setIsSearching(true);
    setSearchResults([]);
    setSelectedUser(null);
    setRateLimitData(null);

    try {
      const params = looksLikeEmail(trimmed)
        ? { email: trimmed }
        : { user_id: trimmed };
      const response = await getV2GetUserRateLimit(params);
      if (response.status !== 200) {
        throw new Error("Failed to fetch rate limit");
      }
      setRateLimitData(response.data);
      setSelectedUser({
        user_id: response.data.user_id,
        user_email: response.data.user_email ?? response.data.user_id,
      });
    } catch (error) {
      console.error("Error fetching rate limit:", error);
      const hint = looksLikeEmail(trimmed)
        ? "No user found with that email address."
        : "Check the user ID and try again.";
      toast({
        title: "Error",
        description: `Failed to fetch rate limits. ${hint}`,
        variant: "destructive",
      });
      setRateLimitData(null);
    } finally {

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Preflight-check the active org against the transfer's two org ids and prompt a switch.
  2. Keep the active-org context fresh on every transfers API call from the frontend.
  3. Include the party org ids in the 4xx response detail to make the mismatch obvious.

Example fix

# before
await reject_transfer(tid, user_id, org_id)

# after
tr = await get_transfer(tid)
if org_id not in (tr.source_org_id, tr.target_org_id):
    raise PermissionError("Active org is not a party; switch org first")
await reject_transfer(tid, user_id, org_id)
Defensive patterns

Strategy: type-guard

Validate before calling

tr = await get_transfer(transfer_id)
if org_id not in (tr.source_org_id, tr.target_org_id):
    raise PermissionError("Active org is not a party; switch org")

Type guard

def org_is_party(tr: TransferResponse, org_id: str) -> bool:
    return org_id in (tr.source_org_id, tr.target_org_id)

Try / catch

try:
    await reject_transfer(tid, user_id, org_id)
except ValueError as e:
    if "not a party" in str(e):
        prompt_org_switch(tr)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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