{"record":{"id":"0f6a2ae39a5dc8a3","repo":"BerriAI/litellm","slug":"only-proxy-admins-may-set-user-id-to-a-different-u","errorCode":null,"errorMessage":"Only proxy admins may set user_id to a different user.","messagePattern":"Only proxy admins may set user_id to a different user\\.","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"litellm/proxy/memory/memory_endpoints.py","lineNumber":281,"sourceCode":") -> tuple[str | None, str | None]:\n    \"\"\"\n    Resolve the (user_id, team_id) to stamp on a new row.\n\n    - PROXY_ADMIN: may override either dimension via the request body.\n    - Everyone else: the requested values must match their own (or be omitted).\n\n    Also rejects identity-less creation: a row with both user_id and team_id\n    NULL is invisible to every non-admin caller (the visibility filter would\n    never match it), so we refuse to create orphan rows unless the caller is\n    a PROXY_ADMIN who is explicitly stamping a global/shared row.\n    \"\"\"\n    if _is_admin(user_api_key_dict):\n        user_id = requested_user_id if requested_user_id is not None else user_api_key_dict.user_id\n        team_id = requested_team_id if requested_team_id is not None else user_api_key_dict.team_id\n        return user_id, team_id\n\n    if requested_user_id is not None and requested_user_id != user_api_key_dict.user_id:\n        raise HTTPException(\n            status_code=403,\n            detail=\"Only proxy admins may set user_id to a different user.\",\n        )\n    if requested_team_id is not None and requested_team_id != user_api_key_dict.team_id:\n        raise HTTPException(\n            status_code=403,\n            detail=\"Only proxy admins may set team_id to a different team.\",\n        )\n    user_id = user_api_key_dict.user_id\n    team_id = user_api_key_dict.team_id\n    if not user_id and not team_id:\n        # Orphan row: no user_id and no team_id means no non-admin can ever\n        # see it again via the visibility filter. Reject up front.\n        raise HTTPException(\n            status_code=400,\n            detail=(\n                \"Cannot create a memory entry without a user_id or team_id. \"\n                \"Authenticate with a key that has a user_id or team_id, or call \"","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/memory/memory_endpoints.py#L263-L299","documentation":"HTTPException(403) from the memory row-identity resolver: a non-admin caller set user_id in the request body to a user other than themselves. Non-admins can only create memory entries stamped with their own identity; admins may override for shared rows.","triggerScenarios":"Thrown at litellm/proxy/memory/memory_endpoints.py:281 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Omit user_id or set it to your own user, or call as a proxy admin."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}