{"record":{"id":"8cdb071e91a1d806","repo":"Significant-Gravitas/AutoGPT","slug":"either-user-id-or-email-query-parameter-is-require","errorCode":null,"errorMessage":"Either user_id or email query parameter is required.","messagePattern":"Either user_id or email query parameter is required\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/admin/rate_limit_admin_routes.py","lineNumber":73,"sourceCode":"\nasync def _resolve_user_id(\n    user_id: Optional[str], email: Optional[str]\n) -> tuple[str, Optional[str]]:\n    \"\"\"Resolve a user_id and email from the provided parameters.\n\n    Returns (user_id, email). Accepts either user_id or email; at least one\n    must be provided.  When both are provided, ``email`` takes precedence.\n    \"\"\"\n    if email:\n        user = await get_user_by_email(email)\n        if not user:\n            raise HTTPException(\n                status_code=404, detail=\"No user found with the provided email.\"\n            )\n        return user.id, email\n\n    if not user_id:\n        raise HTTPException(\n            status_code=400,\n            detail=\"Either user_id or email query parameter is required.\",\n        )\n\n    # We have a user_id; try to look up their email for display purposes.\n    # This is non-critical -- a failure should not block the response.\n    try:\n        resolved_email = await get_user_email_by_id(user_id)\n    except Exception:\n        logger.warning(\"Failed to resolve email for user %s\", user_id, exc_info=True)\n        resolved_email = None\n    return user_id, resolved_email\n\n\n@router.get(\n    \"/rate_limit\",\n    response_model=UserRateLimitResponse,\n    summary=\"Get User Rate Limit\",","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/admin/rate_limit_admin_routes.py#L55-L91","documentation":"HTTP 400 raised by _resolve_user_id when neither email nor user_id was provided on an admin rate-limit endpoint. The helper requires at least one identifier; email is optional but user_id alone is acceptable (its email is then best-effort resolved and a lookup failure never blocks).","triggerScenarios":"Calling a rate-limit admin route with no query parameters at all, or with parameter names the backend doesn't expect (e.g. userID vs user_id), so both resolve to None/empty.","commonSituations":"Frontend sending the identifier in the request body on a GET route; query param renamed during a refactor and callers not updated; empty string from a form field that was never filled; OpenAPI-agnostic scripts guessing parameter names.","solutions":["Include ?user_id=<uuid> or ?email=<address> on the request","Check the route's OpenAPI spec for the exact query parameter names","Ensure GET requests put identifiers in the query string, not the body","Fail fast client-side when neither field is populated"],"exampleFix":"// before\nGET /api/rate_limit\n// after\nGET /api/rate_limit?user_id=883cc9da-fe37-4863-839b-acba022bf3ef","handlingStrategy":"validation","validationCode":"if not (user_id or email):\n    raise ValueError(\"user_id or email query parameter is required\")\nparams = {\"user_id\": user_id} if user_id else {\"email\": email}","typeGuard":null,"tryCatchPattern":"if resp.status_code == 400 and \"required\" in resp.json()[\"detail\"]:\n    # missing identifier — fix parameter plumbing, don't retry as-is","preventionTips":["Use the OpenAPI-generated client so parameter names can't drift","Assert at least one identifier is present before firing the request"],"tags":["http-400","validation","query-params","rate-limit","admin"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}