{"record":{"id":"9d64644e447feb64","repo":"BerriAI/litellm","slug":"user-id-is-required-passed-user-id-data-user-i-9d6464","errorCode":null,"errorMessage":"user_id is required, passed user_id = {data.user_ids}","messagePattern":"user_id is required, passed user_id = (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":500,"severity":"error","filePath":"litellm/proxy/management_endpoints/customer_endpoints.py","lineNumber":803,"sourceCode":"                    type=\"not_found\",\n                    code=404,\n                    param=\"user_ids\",\n                )\n\n            # All users exist, proceed with deletion\n            response: Final = await _typed_table(EndUserRepository(prisma_client)).delete_many(\n                where={\"user_id\": {\"in\": data.user_ids}}\n            )\n            verbose_proxy_logger.debug(\"received response from updating prisma client. response=%s\", response)\n\n            await _evict_end_user_cache_keys(_end_user_cache_keys(data.user_ids))\n\n            return DeleteCustomersResponse(\n                deleted_customers=response,\n                message=\"Successfully deleted customers with ids: \" + str(data.user_ids),\n            )\n        else:\n            raise ValueError(f\"user_id is required, passed user_id = {data.user_ids}\")\n\n        # update based on remaining passed in values\n    except Exception as e:\n        verbose_proxy_logger.error(\"litellm.proxy.proxy_server.delete_end_user(): Exception occured - %s\", e)\n        raise handle_exception_on_proxy(e)\n\n\n@router.get(\n    \"/customer/list\",\n    tags=[\"Customer Management\"],\n    dependencies=[Depends(user_api_key_auth)],\n    response_model=list[CustomerResponse],\n)\n@router.get(\n    \"/end_user/list\",\n    tags=[\"Customer Management\"],\n    include_in_schema=False,\n    dependencies=[Depends(user_api_key_auth)],","sourceCodeStart":785,"sourceCodeEnd":821,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/customer_endpoints.py#L785-L821","documentation":"POST /customer/delete requires user_ids to be a non-empty list; otherwise the endpoint raises ValueError (note the message says 'user_id' although the field is user_ids), which handle_exception_on_proxy converts to HTTP 500. Like the update route, a client payload mistake surfaces as a server error code.","triggerScenarios":"POST /customer/delete with user_ids omitted, null, or an empty array [] in the JSON body.","commonSituations":"Templated scripts rendering an empty list when no candidates matched; cleanup loops that still issue the API call when the filtered set is empty; misconfigured JSON payloads using a different key name.","solutions":["Skip the API call entirely when the candidate list is empty","Require a non-empty user_ids array in the request-building code","Classify this 500 as a client payload bug, not a proxy fault"],"exampleFix":"# before\nresp = post(\"/customer/delete\", {\"user_ids\": []})   # -> 500 ValueError via handler\n\n# after\nif ids:\n    resp = post(\"/customer/delete\", {\"user_ids\": ids})","handlingStrategy":"validation","validationCode":"def delete_payload_valid(payload: dict) -> bool:\n    ids = payload.get(\"user_ids\")\n    return isinstance(ids, list) and len(ids) > 0","typeGuard":"from typing import TypeGuard\n\n\ndef has_non_empty_user_ids(payload: dict) -> TypeGuard[dict]:\n    \"\"\"Narrows to payloads safe to send to POST /customer/delete.\"\"\"\n    ids = payload.get(\"user_ids\")\n    return isinstance(ids, list) and len(ids) > 0 and all(isinstance(i, str) and i for i in ids)","tryCatchPattern":"try:\n    r = httpx.post(f\"{base}/customer/delete\", json=payload, headers=headers)\nexcept httpx.HTTPStatusError as e:\n    if e.response.status_code == 500 and \"user_id is required\" in e.response.text:\n        raise ValueError(\"delete payload must include a non-empty user_ids list\") from e\n    raise","preventionTips":["Guard empty batches before calling the API - an empty delete is a no-op anyway","Use a TypeGuard or pydantic model with min_length=1 on user_ids","Remember the error text says 'user_id' but the field is 'user_ids' - do not chase the wrong key"],"tags":["litellm","required-field","validation","customer-management","http-500"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}