Skip to content

[Bug]: /team/permissions_update endpoint returns 500 instead of 404 for non-existent team #16814

@andresC98

Description

@andresC98

What happened?

Description

The /team/permissions_update endpoint throws an unhandled exception and returns a 500 Internal Server Error when attempting to update permissions for a team that doesn't exist in the database. This is inconsistent with other team management endpoints which properly return 404 Not Found for the same scenario.

Expected Behavior

When calling POST /team/permissions_update with a team_id that doesn't exist, the endpoint should return:

  • Status Code: 404 Not Found
  • Response Body: Proper error message indicating the team doesn't exist

This is consistent with other team endpoints like:

  • /team/block → 404
  • /team/unblock → 404
  • /team/model/add → 404
  • /team/model/delete → 404
  • /team/{team_id}/disable_logging → 404

Actual Behavior

The endpoint returns:

  • Status Code: 500 Internal Server Error
  • Response Body: "Internal Server Error" (no details)

Steps to Reproduce

  1. Call POST /team/permissions_update with a non-existent team_id:
curl -X POST "https://your-litellm-proxy/team/permissions_update" \
  -H "Authorization: Bearer sk-your-master-key" \
  -H "Content-Type: application/json" \
  -d '{
    "team_id": "non-existent-team-id-12345",
    "team_member_permissions": []
  }'
  1. Observe 500 response instead of 404

Relevant log output

Server Error Log:
  Exception in ASGI application
  File "/usr/lib/python3.13/site-packages/litellm/proxy/management_endpoints/team_endpoints.py", line 3227, in team_member_permissions
    existing_team_row = await get_team_object(...)
  File "/usr/lib/python3.13/site-packages/litellm/proxy/auth/auth_checks.py", line 1160, in get_team_object
    raise Exception(
      f"Team doesn't exist in db. Team={team_id}. Create team via `/team/new` call."
    )
  Exception: Team doesn't exist in db. Team={team_id}. Create team via `/team/new` call.

Are you a ML Ops Team?

Yes

What LiteLLM version are you on ?

1.79.1

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions