From 6c386af9c772f6e024ed8b4636dfa3b57502bc41 Mon Sep 17 00:00:00 2001 From: user <70670632+stuxf@users.noreply.github.com> Date: Wed, 29 Apr 2026 23:00:33 +0000 Subject: [PATCH] =?UTF-8?q?fix(team):=20mypy=20=E2=80=94=20guard=20organiz?= =?UTF-8?q?ation=5Fid=20None=20before=20=5Fverify=5Forg=5Faccess=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``LiteLLM_OrganizationTableUpdate.organization_id`` is typed ``Optional[str]`` to allow update payloads that don't change the id. ``_verify_org_access`` expects ``str``. Add an explicit None check that raises 400 before the access guard fires — previously this would have crashed at runtime on a malformed update payload. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../proxy/management_endpoints/organization_endpoints.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/litellm/proxy/management_endpoints/organization_endpoints.py b/litellm/proxy/management_endpoints/organization_endpoints.py index 79b9c459e4b..ee683f322a1 100644 --- a/litellm/proxy/management_endpoints/organization_endpoints.py +++ b/litellm/proxy/management_endpoints/organization_endpoints.py @@ -500,6 +500,12 @@ async def update_organization( if data.updated_by is None: data.updated_by = user_api_key_dict.user_id + if data.organization_id is None: + raise HTTPException( + status_code=400, + detail={"error": "organization_id is required"}, + ) + # IDOR guard: only proxy admins / org admins of THIS org may update # it. Without this, any authenticated key holder could rewrite # another organization's metadata, budgets, and object permissions.