Skip to content

fix: 1.99.0-rc2 UI bug batch (empty org on key create, session pagination, access group rename/delete) - #39436

Merged
yassin-berriai merged 14 commits into
litellm_internal_stagingfrom
litellm_fix_rc2_ui_bug_batch
Sep 3, 2026
Merged

yassin-berriai merged 14 commits into
litellm_internal_stagingfrom
litellm_fix_rc2_ui_bug_batch

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Clearing the org picker on key create sends organization_id: "" and 500s
  • Request Logs shows one model per conversation row, the newest call's, so a conversation that alternated two models reads as if it used one (fix(ui): paginate request logs by session groups server-side #39257 on staging already pages by conversation and aggregates the Type counts server-side; this PR builds on it)
  • Renaming or deleting a model leaves unified access groups on the old name
  • POST /model/update silently drops model_name, so Terraform renames never land

How it solves it:

  • Key create and edit forms drop a cleared org; the API treats "" as unset
  • /spend/logs/ui adds session_models (the conversation's distinct models, capped at 10) to the per-session aggregate fix(ui): paginate request logs by session groups server-side #39257 already runs, and the Model column lists them
  • The Type badge stays a conversation badge with its LLM/MCP breakdown when an MCP call is the row's representative
  • Model rename and delete rewrite access_model_names in every group that named the model
  • POST /model/update persists model_name and runs the same rewrite

User Flow

Bug 1: key create with a cleared organization picker

Before: an admin who picks an organization on the Create Key form and then clears it gets a server error instead of a key

  1. They open http://localhost:4000/ui/?page=api-keys and click "+ Create New Key"
  2. They pick an organization in the Organization picker, then click the picker's clear (X) so the key belongs to no organization
  3. They fill in a Key Name and click Create Key
  4. The page sends POST http://localhost:4000/key/generate with "organization_id": "" and gets a 500 reading "Organization doesn't exist in db. Organization=. Create organization via /organization/new call."
  5. A red toast shows that error and no key is created
  6. On an existing key that belongs to an organization, they open its Settings tab, click Edit Settings, clear the Organization picker and click Save Changes; the page sends POST http://localhost:4000/key/update with "organization_id": "" and gets a 400 reading "Authentication Error, Foreign key constraint failed on the field: LiteLLM_VerificationToken_organization_id_fkey (index)", and the key keeps its organization

After: the same clicks create a key with no organization

  1. They open http://localhost:4000/ui/?page=api-keys and click "+ Create New Key"
  2. They pick an organization in the Organization picker, then click the picker's clear (X) so the key belongs to no organization
  3. They fill in a Key Name and click Create Key
  4. The page sends POST http://localhost:4000/key/generate with no organization id and gets a 200 with the new sk-... key
  5. The key shows up in the Virtual Keys table with an empty Organization column, and a client that posts "organization_id": "" directly to POST http://localhost:4000/key/generate gets the same 200
  6. On an existing key that belongs to an organization, the same Edit Settings clicks send POST http://localhost:4000/key/update with "organization_id": null and get a 200, and the key's Organization reads "Not Set" afterwards

Bug 2: Request Logs sessions view

Before: an admin reviewing a conversation that alternated two models sees only one of them in the Model column

  1. Their app makes 196 calls to POST http://localhost:4000/v1/chat/completions across three conversations (4, 72, and 120 calls, alternating gpt-5.4-nano and claude-haiku-4-5, each conversation tagged with its own x-litellm-session-id)
  2. They open http://localhost:4000/ui/?page=logs (Request Logs)
  3. Page 1 shows three rows, one per conversation, with Type badges 120, 72, and 4 whose hover text matches, and the footer says "Showing 1-3 of 3" (fix(ui): paginate request logs by session groups server-side #39257 already fixed the paging and counts on staging)
  4. The Model column of each row shows only the newest call's model, so a conversation that alternated gpt-5.4-nano and claude-haiku-4-5 reads as one of them and nothing on the page says the other model was used

After: each conversation row lists every model it used

  1. Their app makes 196 calls to POST http://localhost:4000/v1/chat/completions across three conversations (4, 72, and 120 calls, alternating gpt-5.4-nano and claude-haiku-4-5, each conversation tagged with its own x-litellm-session-id)
  2. They open http://localhost:4000/ui/?page=logs (Request Logs)
  3. Page 1 shows three rows, one per conversation, with Type badges 120, 72, and 4 whose hover text matches, and the footer says "Showing 1-3 of 3"
  4. The Model column reads "claude-haiku-4-5, gpt-5.4-nano" for every conversation that used both models, and a single-model conversation keeps its provider logo next to its one model

Bug 3: model rename or delete and access groups

Before: an admin who renames or deletes a model finds their access group still granting the old name

  1. They send POST http://localhost:4000/model/new with "model_name": "lit6695-rename-me" and get a 200 with the model id
  2. They send POST http://localhost:4000/v1/access_group with "access_model_names": ["lit6695-rename-me"] and get a 200
  3. They rename the model from http://localhost:4000/ui/?page=models (the edit form sends PATCH http://localhost:4000/model/{id}/update with "model_name": "lit6695-renamed") and get a 200 with the new name
  4. GET http://localhost:4000/v1/access_group still lists ["lit6695-rename-me"], and http://localhost:4000/ui/?page=access-groups shows the same stale name
  5. Their Terraform apply sends POST http://localhost:4000/model/update with "model_name": "lit6695-renamed-tf" and gets a 200, but GET http://localhost:4000/model/info still shows lit6695-renamed
  6. They send POST http://localhost:4000/model/delete and get a 200, and GET http://localhost:4000/v1/access_group still lists ["lit6695-rename-me"], a model that no longer exists
  7. A key attached to that group cannot call the renamed model, because the group only grants a name nothing serves

After: the group follows the rename and drops the deleted name

  1. They send POST http://localhost:4000/model/new with "model_name": "lit6695-rename-me" and get a 200 with the model id
  2. They send POST http://localhost:4000/v1/access_group with "access_model_names": ["lit6695-rename-me"] and get a 200
  3. They rename the model from http://localhost:4000/ui/?page=models (the edit form sends PATCH http://localhost:4000/model/{id}/update with "model_name": "lit6695-renamed") and get a 200 with the new name
  4. GET http://localhost:4000/v1/access_group now lists ["lit6695-renamed"], and http://localhost:4000/ui/?page=access-groups shows the new name
  5. Their Terraform apply sends POST http://localhost:4000/model/update with "model_name": "lit6695-renamed-tf" and gets a 200, GET http://localhost:4000/model/info shows lit6695-renamed-tf, and the group lists ["lit6695-renamed-tf"]
  6. They send POST http://localhost:4000/model/delete and get a 200, and GET http://localhost:4000/v1/access_group shows the group with an empty model list
  7. A key attached to that group keeps calling the model under each new name until the model is deleted; when a second deployment still carries the old name, the group keeps the old name and gains the new one, and a delete only drops a name once no deployment carries it

Relevant issues

Linear ticket

Resolves LIT-6695

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Shared setup: each leg runs its own proxy with a fresh Postgres, STORE_MODEL_IN_DB=True and --num_workers 2, plus the dashboard dev server (npm run dev in ui/litellm-dashboard), on the ports named under its heading; $P and $K are that leg's proxy URL and master key, and the config defines gpt-5.4-nano and claude-haiku-4-5. Bug 2 data comes from this loop, which makes 196 real OpenAI and Anthropic calls across three conversations:

for spec in small-4:4 mid-72:72 big-120:120; do
  sid=lit6695-session-${spec%%:*}; n=${spec##*:}
  for i in $(seq 1 $n); do
    model=gpt-5.4-nano; (( i % 2 == 0 )) && model=claude-haiku-4-5
    curl -s -o /dev/null "$P/v1/chat/completions" -H "Authorization: Bearer $K" -H 'Content-Type: application/json' \
      -H "x-litellm-session-id: $sid" \
      -d "{\"model\":\"$model\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with the single word ok\"}],\"max_tokens\":5}" &
    (( i % 8 == 0 )) && wait
  done
  wait
done

Before (291e84e)

Proxy at 291e84e on http://localhost:22201 with two workers, dashboard dev server on http://localhost:53502, master key sk-lit6695-qa-before

Key create with a cleared organization picker

  1. Create an organization to pick and clear
curl -s -X POST $P/organization/new -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"organization_alias":"lit6695-org"}'
{"organization_id":"d1981cf0-0757-4e2a-a118-9ae4eb95ba5c","organization_alias":"lit6695-org","budget_id":"b0e40fa2-c2a5-4a1f-b91d-4ab3a0cf7759","spend":0.0,"metadata":{},"models":[], ...}   HTTP 200
  1. Open http://localhost:53502/api-keys/, click "+ Create New Key", pick lit6695-org in the Organization picker, click the picker's Clear (X), set Key Name lit6695-qa-key, click Create Key
POST http://localhost:22201/key/generate  ->  HTTP 500
request body:  {"user_id":"default_user_id","organization_id":"","key_alias":"lit6695-qa-key","models":[],"key_type":"llm_api","duration":null,"metadata":{}}
response body: {"error":{"message":"Organization doesn't exist in db. Organization=. Create organization via `/organization/new` call.","type":"internal_server_error","param":"None","code":"500"}}

toast: "Server Error
Error creating the key: Error: Organization doesn't exist in db. Organization=. Create organization via `/organization/new` call."
key shown in modal: no
  1. Same modal, Organization picker never touched, Key Name lit6695-control-key, click Create Key
POST http://localhost:22201/key/generate  ->  HTTP 200
request body:  {"user_id":"default_user_id","team_id":null,"key_alias":"lit6695-control-key","models":[],"key_type":"llm_api","duration":null,"metadata":{}}
response body: {"key_alias":"lit6695-control-key","duration":null,"models":[],"spend":0.0,"max_budget":null,"user_id":"default_user_id","team_id":null, ...}

An untouched picker leaves organization_id out of the payload; picking an organization and clearing it sends organization_id: ""

  1. Open that key (http://localhost:53502/api-keys/?key=b9cbae2c...), Settings tab, Edit Settings, pick lit6695-org, click Clear, click Save Changes
POST http://localhost:22201/key/update  ->  HTTP 400
request body:  {"key_alias":"lit6695-control-key","models":[],"max_budget":null,"budget_duration":null,"tpm_limit":null,"tpm_limit_type":null,"rpm_limit":null,"rpm_limit_type":null,"throttle_on_budget_exceeded":false,"enable_prompt_caching":false,"max_parallel_requests":null,"access_group_ids":[],"organization_id":"","metadata":{},"duration":null,"token":"b9cbae2c...","disabled_callbacks":[],"auto_rotate":false,"rotation_interval":null,"tag_rpm_limit":{},"key":"b9cbae2c...", ...}
response body: {"error":{"message":"Authentication Error, Foreign key constraint failed on the field: `LiteLLM_VerificationToken_organization_id_fkey (index)`","type":"auth_error","param":"None","code":"400"}}

toast: "Error
Authentication Error, Foreign key constraint failed on the field: `LiteLLM_VerificationToken_organization_id_fkey (index)`"
  1. The same payloads the form sends, straight at the API
curl -s -X POST $P/key/generate -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"key_alias":"lit6695-api-key","organization_id":"","models":[]}'
{"error":{"message":"Organization doesn't exist in db. Organization=. Create organization via `/organization/new` call.","type":"internal_server_error","param":"None","code":"500"}}   HTTP 500

curl -s -X POST $P/key/update -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"key":"<existing key hash>","organization_id":"","models":[]}'
{"error":{"message":"Authentication Error, Foreign key constraint failed on the field: `LiteLLM_VerificationToken_organization_id_fkey (index)`","type":"auth_error","param":"None","code":"400"}}   HTTP 400

Request Logs sessions view

  1. Run the 196-call loop from the shared setup (all 200s: 120 calls in lit6695-session-big-120, 72 in lit6695-session-mid-72, 4 in lit6695-session-small-4, each half gpt-5.4-nano and half claude-haiku-4-5)
done 196 calls in 20.4s, 8 in flight
   ('lit6695-session-big-120', 'claude-haiku-4-5', 200) 60
   ('lit6695-session-big-120', 'gpt-5.4-nano', 200) 60
   ('lit6695-session-mid-72', 'claude-haiku-4-5', 200) 36
   ('lit6695-session-mid-72', 'gpt-5.4-nano', 200) 36
   ('lit6695-session-small-4', 'claude-haiku-4-5', 200) 2
   ('lit6695-session-small-4', 'gpt-5.4-nano', 200) 2
non-200: []
  1. Open http://localhost:53502/logs/ and page through Request Logs, hovering the Type badge on every row
page 1: "Rows per page 10", "Showing 1-10 of 20", "Page 1 of 2"
  Type badge 4     tooltip "4 LLM • 0 cache hit"     Session lit6695-session-small-4   Model anthropic/claude-haiku-4-5   Cost $0.000081 session total
  Type badge 72    tooltip "72 LLM • 0 cache hit"    Session lit6695-session-mid-72    Model anthropic/claude-haiku-4-5   Cost $0.001463 session total
  Type badge 120   tooltip "120 LLM • 0 cache hit"   Session lit6695-session-big-120   Model anthropic/claude-haiku-4-5   Cost $0.002439 session total
  7 more rows, all Type "LLM" / Status "Failure" / empty Model, one per dashboard request made with a stale token

One row per conversation, each on a single page, and the badge matches its tooltip on all three. The Model column shows anthropic/claude-haiku-4-5 for every conversation even though each one alternated gpt-5.4-nano and claude-haiku-4-5

  1. Click the lit6695-session-big-120 row to open the session drawer
GET http://localhost:22201/spend/logs/session/ui?session_id=lit6695-session-big-120&page=1&page_size=100
GET http://localhost:22201/spend/logs/session/ui?session_id=lit6695-session-big-120&page=2&page_size=100

Request chatcmpl-3e93b560-e724-40da-90ca-1ec05c8133df details
SESSION lit6695-ses...
120 req·120 LLM·$0.002439·13.30s
0/120 cached
gpt-5.4-nano        3.064s · $0.000008 · 12 tok
gpt-5.4-nano        2.774s · $0.000008 · 12 tok
claude-haiku-4-5    2.655s · $0.000033 · 13 tok
gpt-5.4-nano        2.443s · $0.000008 · 12 tok
gpt-5.4-nano        2.373s · $0.000008 · 12 tok
claude-haiku-4-5    2.081s · $0.000033 · 13 tok
   (continues for all 120 calls, both models)

The drawer lists both models for the conversation whose Model cell reads only anthropic/claude-haiku-4-5

  1. The API the page reads
curl -s "$P/spend/logs/ui?group_by_session=true&page=1&page_size=50&start_date=$START&end_date=$END&sort_by=startTime&sort_order=desc" -H "Authorization: Bearer $K"
HTTP 200 | total: 20 | total_pages: 1 | len(data): 20
  {"request_id": "chatcmpl-0cab98d5-d595-48da-af0b-aa4484bc7449", "session_id": "lit6695-session-small-4", "session_total_count": 4, "session_llm_count": 4, "session_agent_count": 0, "session_mcp_count": null, "session_cache_hit_count": 0, "session_models": null, "model": "anthropic/claude-haiku-4-5"}
  {"request_id": "chatcmpl-6178bb31-d35b-4c53-9a8b-b12e4de53119", "session_id": "lit6695-session-mid-72", "session_total_count": 72, "session_llm_count": 72, "session_agent_count": 0, "session_mcp_count": null, "session_cache_hit_count": 0, "session_models": null, "model": "anthropic/claude-haiku-4-5"}
  {"request_id": "chatcmpl-3e93b560-e724-40da-90ca-1ec05c8133df", "session_id": "lit6695-session-big-120", "session_total_count": 120, "session_llm_count": 120, "session_agent_count": 0, "session_mcp_count": null, "session_cache_hit_count": 0, "session_models": null, "model": "anthropic/claude-haiku-4-5"}
  17 more rows, one per failed dashboard request, session_total_count 1 and model ""
page 2: HTTP 200 total=20 total_pages=1 len(data)=0
page 3: HTTP 200 total=20 total_pages=1 len(data)=0

wall clock for that call, 7 runs: [781, 151, 685, 177, 233, 138, 169] ms, median 177 ms

session_llm_count is server-side and correct, session_models is null on every row, and the row's model is the single most recent call's model

  1. The same window without grouping, for contrast
curl -s "$P/spend/logs/ui?page=1&page_size=50&start_date=$START&end_date=$END&sort_by=startTime&sort_order=desc" -H "Authorization: Bearer $K"
HTTP 200 | total: 213 | total_pages: 5 | page: 1 | page_size: 50 | len(data): 50
  row01: {"session_id": "lit6695-session-small-4", "model": "anthropic/claude-haiku-4-5"}
  row02: {"session_id": "lit6695-session-small-4", "model": "openai/gpt-5.4-nano"}
  ...
  row05: {"session_id": "lit6695-session-mid-72", "model": "anthropic/claude-haiku-4-5"}
  row06: {"session_id": "lit6695-session-mid-72", "model": "openai/gpt-5.4-nano"}
one row per call, 213 = the 196 loop calls plus 17 failed dashboard requests

Model rename or delete and access groups

  1. Create a model and a unified access group naming it
curl -s -X POST $P/model/new -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"model_name":"lit6695-rename-me","litellm_params":{"model":"openai/gpt-5.4-nano","api_key":"os.environ/OPENAI_API_KEY"},"model_info":{"access_groups":["lit6695-legacy-group"]}}'
{"model_id":"aa8078c1-3c26-4a32-b3a5-45b3fc00dbd4","model_name":"lit6695-rename-me", ...,"model_info":{"id":"aa8078c1-3c26-4a32-b3a5-45b3fc00dbd4","db_model":false,"access_groups":["lit6695-legacy-group"]}, ...}   HTTP 200

curl -s -X POST $P/v1/access_group -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"access_group_name":"lit6695-unified-group","access_model_names":["lit6695-rename-me"]}'
{"access_group_id":"35d2fb06-9a32-400f-9385-de95a3819e54","access_group_name":"lit6695-unified-group","description":null,"access_model_names":["lit6695-rename-me"],"access_mcp_server_ids":[],"access_agent_ids":[],"assigned_team_ids":[],"assigned_key_ids":[], ...}   HTTP 201

curl -s $P/access_group/lit6695-legacy-group/info -H "Authorization: Bearer $K"
{"access_group":"lit6695-legacy-group","model_names":["lit6695-rename-me"],"deployment_count":1,"spend":0.0,"budget":null}   HTTP 200
  1. Rename it from the UI: http://localhost:53502/models-and-endpoints/, open the lit6695-rename-me row, Edit Settings, set Model Name to lit6695-renamed, Save Changes
PATCH http://localhost:22201/model/aa8078c1-3c26-4a32-b3a5-45b3fc00dbd4/update  ->  HTTP 200
request body: {"model_name":"lit6695-renamed","litellm_params":{...,"model":"openai/gpt-5.4-nano","tags":[],"guardrails":[]},"model_info":{"id":"aa8078c1-3c26-4a32-b3a5-45b3fc00dbd4","db_model":true,"blocked":false,"access_groups":["lit6695-legacy-group"], ...}}
  1. The group still names the old model, and the old name no longer serves anything
curl -s $P/v1/access_group -H "Authorization: Bearer $K"
[{"access_group_name": "lit6695-unified-group", "access_model_names": ["lit6695-rename-me"]}]

curl -s $P/access_group/lit6695-legacy-group/info -H "Authorization: Bearer $K"
{"access_group":"lit6695-legacy-group","model_names":["lit6695-renamed"],"deployment_count":1,"spend":0.0,"budget":null}   HTTP 200

curl -s "$P/model/info?litellm_model_id=aa8078c1-3c26-4a32-b3a5-45b3fc00dbd4" -H "Authorization: Bearer $K"     (both workers, 8s apart, 8 polls)
poll 1: model/info=lit6695-renamed | v1/models(lit6695)=lit6695-renamed
...
poll 8: model/info=lit6695-renamed | v1/models(lit6695)=lit6695-renamed

curl -s -X POST $P/v1/chat/completions -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"model":"lit6695-renamed","messages":[{"role":"user","content":"hi"}],"max_tokens":5}'
{"id":"chatcmpl-EJtO4oPYZ8QTGBoIXiEHd6DvemLNS","model":"lit6695-renamed", ...}   HTTP 200
curl -s -X POST $P/v1/chat/completions -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"model":"lit6695-rename-me","messages":[{"role":"user","content":"hi"}],"max_tokens":5}'
{"error":{"message":"/chat/completions: Invalid model name passed in model=lit6695-rename-me. Call `/v1/models` to view available models for your key.", ...}}   HTTP 400
curl -s -X POST $P/v1/chat/completions -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"model":"lit6695-unified-group","messages":[{"role":"user","content":"hi"}],"max_tokens":5}'
{"error":{"message":"/chat/completions: Invalid model name passed in model=lit6695-unified-group. Call `/v1/models` to view available models for your key.", ...}}   HTTP 400

The group derived from the deployment (lit6695-legacy-group) follows the rename; the unified access group keeps the dead name

  1. Rename through Terraform (litellm_model resource, model_name from TF_VAR_model_name) after both workers see the first apply's model
TF_VAR_model_name=lit6695-tf-model terraform apply -auto-approve
litellm_model.renamed: Creation complete after 1s [id=148ab1ec-a2ad-4029-a3f7-e65ce1427e6c]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

curl -s -X POST $P/v1/access_group -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"access_group_name":"lit6695-tf-group","access_model_names":["lit6695-tf-model"]}'
{"access_group_id":"1b43db96-429b-49a8-b543-d7de7e8a7518","access_group_name":"lit6695-tf-group","access_model_names":["lit6695-tf-model"], ...}   HTTP 201

TF_VAR_model_name=lit6695-tf-renamed terraform plan
  # litellm_model.renamed will be updated in-place
  ~ resource "litellm_model" "renamed" {
        id         = "148ab1ec-a2ad-4029-a3f7-e65ce1427e6c"
      ~ model_name = "lit6695-tf-model" -> "lit6695-tf-renamed"
        # (20 unchanged attributes hidden)
    }
Plan: 0 to add, 1 to change, 0 to destroy.

TF_VAR_model_name=lit6695-tf-renamed terraform apply -auto-approve
litellm_model.renamed: Modifications complete after 0s [id=148ab1ec-a2ad-4029-a3f7-e65ce1427e6c]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

curl -s "$P/model/info?litellm_model_id=148ab1ec-a2ad-4029-a3f7-e65ce1427e6c" -H "Authorization: Bearer $K"   (8 polls, 0s to 56s after the apply)
poll 1 (0s after apply):  model/info=lit6695-tf-model | v1/models=lit6695-renamed,lit6695-tf-model
poll 8 (56s after apply): model/info=lit6695-tf-model | v1/models=lit6695-renamed,lit6695-tf-model

curl -s $P/v1/access_group -H "Authorization: Bearer $K"
[{"access_group_name": "lit6695-tf-group", "access_model_names": ["lit6695-tf-model"]}, {"access_group_name": "lit6695-unified-group", "access_model_names": ["lit6695-rename-me"]}]

curl -s -X POST $P/v1/chat/completions ... -d '{"model":"lit6695-tf-renamed", ...}'
{"error":{"message":"/chat/completions: Invalid model name passed in model=lit6695-tf-renamed. Call `/v1/models` to view available models for your key.", ...}}   HTTP 400
curl -s -X POST $P/v1/chat/completions ... -d '{"model":"lit6695-tf-model", ...}'
{"id":"chatcmpl-EJtSVDdCCufDl0x40sVCtNp32ehpz","model":"lit6695-tf-model", ...}   HTTP 200

Terraform believes the rename landed (terraform state show reads model_name = "lit6695-tf-renamed"), the proxy never took it, and a call to lit6695-tf-renamed gets HTTP 400 "Invalid model name"

  1. Delete the model renamed in the UI; the group keeps a name nothing serves
curl -s -X POST $P/model/delete -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"id":"aa8078c1-3c26-4a32-b3a5-45b3fc00dbd4"}'
{"message":"Model: aa8078c1-3c26-4a32-b3a5-45b3fc00dbd4 deleted successfully"}   HTTP 200

curl -s $P/v1/access_group -H "Authorization: Bearer $K"
[{"access_group_name": "lit6695-tf-group", "access_model_names": ["lit6695-tf-model"]}, {"access_group_name": "lit6695-unified-group", "access_model_names": ["lit6695-rename-me"]}]

curl -s $P/access_group/lit6695-legacy-group/info -H "Authorization: Bearer $K"
{"detail":{"error":"Access group 'lit6695-legacy-group' not found"}}   HTTP 404

curl -s $P/model/info -H "Authorization: Bearer $K"     (lit6695 entries left)
['lit6695-tf-model']
  1. Sibling case: two deployments share the name lit6695-shared, a group names it, one deployment is renamed and the other deleted
POST $P/model/new {"model_name":"lit6695-shared","litellm_params":{"model":"openai/gpt-5.4-nano", ...}}      -> 100d8fde-0f1d-4726-b5f2-3db188471c0f
POST $P/model/new {"model_name":"lit6695-shared","litellm_params":{"model":"anthropic/claude-haiku-4-5", ...}} -> 4af61df2-ae6b-470f-bdd9-a45030da6227

curl -s -X POST $P/v1/access_group ... -d '{"access_group_name":"lit6695-shared-group","access_model_names":["lit6695-shared"]}'
{"access_group_id":"9693449e-7ba3-4fcd-b056-8de9f3e3e871","access_group_name":"lit6695-shared-group","access_model_names":["lit6695-shared"], ...}   HTTP 201

PATCH $P/model/4af61df2-ae6b-470f-bdd9-a45030da6227/update {"model_name":"lit6695-shared-b"}   HTTP 200  (model_name now: lit6695-shared-b)
curl -s $P/v1/access_group ...   {"access_group_name": "lit6695-shared-group", "access_model_names": ["lit6695-shared"]}

POST $P/model/delete {"id":"100d8fde-0f1d-4726-b5f2-3db188471c0f"}
{"message":"Model: 100d8fde-0f1d-4726-b5f2-3db188471c0f deleted successfully"}   HTTP 200
curl -s $P/v1/access_group ...   {"access_group_name": "lit6695-shared-group", "access_model_names": ["lit6695-shared"]}
curl -s $P/model/info ...        ['lit6695-tf-model', 'lit6695-shared-b']

curl -s -X POST $P/v1/chat/completions ... -d '{"model":"lit6695-shared", ...}'
{"error":{"message":"/chat/completions: Invalid model name passed in model=lit6695-shared. Call `/v1/models` to view available models for your key.", ...}}   HTTP 400

After (7804574)

Proxy at 7804574 on http://localhost:29713 with two workers, dashboard dev server on http://localhost:43858, master key sk-lit6695-qa-after

Key create with a cleared organization picker

  1. Create an organization to pick and clear
curl -s -X POST $P/organization/new -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"organization_alias":"lit6695-org"}'
{"organization_id":"2c810c85-037d-4dde-a47c-4a9471b67797","organization_alias":"lit6695-org","budget_id":"cc0d1732-6cef-410b-9176-37f004e4bb96","spend":0.0,"metadata":{},"models":[], ...}   HTTP 200
  1. Open http://localhost:43858/api-keys/, click "+ Create New Key", pick lit6695-org in the Organization picker, click the picker's Clear (X), set Key Name lit6695-qa-key, click Create Key
POST http://localhost:29713/key/generate  ->  HTTP 200
request body:  {"user_id":"default_user_id","key_alias":"lit6695-qa-key","models":[],"key_type":"llm_api","duration":null,"metadata":{}}
response body: {"key_alias":"lit6695-qa-key","duration":null,"models":[],"spend":0.0,"max_budget":null,"user_id":"default_user_id","team_id":null, ...,"key":"sk-9LHrid...", ...}

modal: "Save your Key
Please save this secret key somewhere safe and accessible. For security reasons, you will not be able to view it again through your LiteLLM account. If you lose this secret key, you will need to generate a new one.
Virtual Key: sk-9LHrid..."
key shown in modal: yes

Screenshots a4_s1_create_key_org_picked.png, a4_s1_create_key_org_cleared.png, a4_s1_create_key_result.png

  1. Same modal, Organization picker never touched, Key Name lit6695-control-key, click Create Key
POST http://localhost:29713/key/generate  ->  HTTP 200
request body:  {"user_id":"default_user_id","team_id":null,"key_alias":"lit6695-control-key","models":[],"key_type":"llm_api","duration":null,"metadata":{}}
response body: {"key_alias":"lit6695-control-key","duration":null,"models":[],"spend":0.0,"max_budget":null,"user_id":"default_user_id","team_id":null, ...}

Both paths now leave organization_id out of the payload; picking an organization and clearing it no longer sends organization_id: ""

  1. A key that really carries an organization, then loses it from the UI
curl -s -X POST $P/key/generate -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"key_alias":"lit6695-org-key","organization_id":"2c810c85-037d-4dde-a47c-4a9471b67797","models":[]}'
{"key_alias":"lit6695-org-key","organization_id":"2c810c85-037d-4dde-a47c-4a9471b67797","token":"8ea54ce8d37c16c41e1d47eeaaf1b0c6014af3b389575f7bcb0d4ef3171c0f25", ...}   HTTP 200

curl -s "$P/key/info?key=8ea54ce8..." -H "Authorization: Bearer $K"      (before the edit)
{
 "key_alias": "lit6695-org-key",
 "key_name": "sk-...PP9A",
 "organization_id": "2c810c85-037d-4dde-a47c-4a9471b67797",
 "team_id": null,
 "user_id": null
}

Open that key at http://localhost:43858/api-keys/, Settings tab, Edit Settings, pick lit6695-org in the Organization picker, click Clear, click Save Changes

POST http://localhost:29713/key/update  ->  HTTP 200
request body:  {"key_alias":"lit6695-org-key","models":[],"max_budget":null,"budget_duration":null,"tpm_limit":null,"tpm_limit_type":null,"rpm_limit":null,"rpm_limit_type":null,"throttle_on_budget_exceeded":false,"enable_prompt_caching":false,"max_parallel_requests":null,"access_group_ids":[],"organization_id":null,"metadata":{},"duration":null,"token":"8ea54ce8d37c16c41e1d47eeaaf1b0c6014af3b389575f7bcb0d4ef3171c0f25","disabled_callbacks":[],"auto_rotate":false,"rotation_interval":null,"tag_rpm_limit":{},"key":"8ea54ce8...","object_permission":{"vector_stores":[],"mcp_servers":[],"mcp_access_groups":[],"mcp_toolsets":[],"mcp_tool_permissions":{},"agents":[],"agent_access_groups":[]}}
response body: {"key":"8ea54ce8...","token":"8ea54ce8...","key_name":"sk-...PP9A","key_alias":"lit6695-org-key","soft_budget_cooldown":false,"spend":0.0,"expires":null,"models":[],"aliases":{},"config":{},"router_settings":{},"user_id":null,"team_id":null, ...}

curl -s "$P/key/info?key=8ea54ce8..." -H "Authorization: Bearer $K"      (after the edit)
{
 "key_alias": "lit6695-org-key",
 "key_name": "sk-...PP9A",
 "organization_id": null,
 "team_id": null,
 "user_id": null
}

key detail header after the edit: "lit6695-org-key ... TEAM - ORGANIZATION -"

The form sends "organization_id": null instead of "", the call is a 200, and the organization the key really had is gone. Screenshots a4_s1_edit_org_selected.png, a4_s1_edit_org_cleared.png, a4_s1_edit_key_after_header.png

The edit form's Organization picker opens empty (placeholder "All Organizations") even on a key that has an organization, which is why the run picks lit6695-org first and then clears it. That prefill gap is not part of this PR's diff and behaves the same at the base commit

  1. The same payloads the form used to send, straight at the API
curl -s -X POST $P/key/generate -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"key_alias":"lit6695-api-key","organization_id":"","models":[]}'
{"key_alias":"lit6695-api-key","duration":null,"models":[],"spend":0.0,"max_budget":null,"user_id":null,"team_id":null,"agent_id":null,"max_parallel_requests":null,"metadata":{}, ...}   HTTP 200

curl -s -X POST $P/key/update -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"key":"8ea54ce8...","organization_id":"","models":[]}'
{"key":"8ea54ce8...","token":"8ea54ce8...","key_name":"sk-...PP9A","key_alias":"lit6695-org-key","soft_budget_cooldown":false,"spend":0.0,"expires":null,"models":[],"aliases":{},"config":{},"router_settings":{}, ...}   HTTP 200

Both read back with organization_id: null

Request Logs sessions view

  1. Run the 196-call loop from the shared setup (all 200s: 120 calls in lit6695-session-big-120, 72 in lit6695-session-mid-72, 4 in lit6695-session-small-4, each half gpt-5.4-nano and half claude-haiku-4-5)
done 196 calls in 21.0s, 8 in flight
   ('lit6695-session-big-120', 'claude-haiku-4-5', 200) 60
   ('lit6695-session-big-120', 'gpt-5.4-nano', 200) 60
   ('lit6695-session-mid-72', 'claude-haiku-4-5', 200) 36
   ('lit6695-session-mid-72', 'gpt-5.4-nano', 200) 36
   ('lit6695-session-small-4', 'claude-haiku-4-5', 200) 2
   ('lit6695-session-small-4', 'gpt-5.4-nano', 200) 2
non-200: []
  1. Open http://localhost:43858/logs/ and page through Request Logs, hovering the Type badge on every row
page 1: "Rows per page 10", "Showing 1-8 of 8", "Page 1 of 1"
  Type badge 4     tooltip "4 LLM • 0 cache hit"     Session lit6695-session-small-4   Model anthropic/claude-haiku-4-5, openai/gpt-5.4-nano   Cost $0.000081 session total
  Type badge 72    tooltip "72 LLM • 0 cache hit"    Session lit6695-session-mid-72    Model anthropic/claude-haiku-4-5, openai/gpt-5.4-nano   Cost $0.001463 session total
  Type badge 120   tooltip "120 LLM • 0 cache hit"   Session lit6695-session-big-120   Model anthropic/claude-haiku-4-5, openai/gpt-5.4-nano   Cost $0.002439 session total
  5 more rows, all Type "LLM" / Status "Failure" / empty Model, one per dashboard request made with a stale token

One row per conversation, each on a single page, the badge matches its tooltip on all three, and the Model column now lists both models each conversation actually used. Screenshots a4_s2_logs_page1.png, a4_s2_badge_tooltip.png

  1. Click the lit6695-session-big-120 row to open the session drawer
GET http://localhost:29713/spend/logs/session/ui?session_id=lit6695-session-big-120&page=1&page_size=100
GET http://localhost:29713/spend/logs/session/ui?session_id=lit6695-session-big-120&page=2&page_size=100

Request chatcmpl-4961eba5-3901-4cd5-b768-184f1b4fbe6a details
SESSION lit6695-ses...
120 req·120 LLM·$0.002439·11.54s
0/120 cached
gpt-5.4-nano        2.391s · $0.000008 · 12 tok
gpt-5.4-nano        1.859s · $0.000008 · 12 tok
gpt-5.4-nano        1.575s · $0.000008 · 12 tok
claude-haiku-4-5    1.443s · $0.000033 · 13 tok
   (continues for all 120 calls, both models)

The drawer and the Model cell now agree: both list gpt-5.4-nano and claude-haiku-4-5. Screenshot a4_s2_session_drawer.png

  1. The API the page reads
curl -s "$P/spend/logs/ui?group_by_session=true&page=1&page_size=50&start_date=$START&end_date=$END&sort_by=startTime&sort_order=desc" -H "Authorization: Bearer $K"
HTTP 200 | total: 8 | total_pages: 1 | len(data): 8
  {"request_id": "chatcmpl-5da1c9cc-2a8d-4747-817e-c0c5dd39a0ce", "session_id": "lit6695-session-small-4", "session_total_count": 4, "session_llm_count": 4, "session_agent_count": 0, "session_mcp_count": null, "session_cache_hit_count": 0, "session_models": ["anthropic/claude-haiku-4-5", "openai/gpt-5.4-nano"], "model": "anthropic/claude-haiku-4-5"}
  {"request_id": "chatcmpl-13ac7d02-631f-4b15-91eb-60f445f3f317", "session_id": "lit6695-session-mid-72", "session_total_count": 72, "session_llm_count": 72, "session_agent_count": 0, "session_mcp_count": null, "session_cache_hit_count": 0, "session_models": ["anthropic/claude-haiku-4-5", "openai/gpt-5.4-nano"], "model": "anthropic/claude-haiku-4-5"}
  {"request_id": "chatcmpl-4961eba5-3901-4cd5-b768-184f1b4fbe6a", "session_id": "lit6695-session-big-120", "session_total_count": 120, "session_llm_count": 120, "session_agent_count": 0, "session_mcp_count": null, "session_cache_hit_count": 0, "session_models": ["anthropic/claude-haiku-4-5", "openai/gpt-5.4-nano"], "model": "anthropic/claude-haiku-4-5"}
  5 more rows, one per failed dashboard request, session_total_count [1] and model ['']
page 2: HTTP 200 total=8 total_pages=1 len(data)=0
page 3: HTTP 200 total=8 total_pages=1 len(data)=0

wall clock for that call, 7 runs: [64, 63, 65, 73, 72, 68, 72] ms, median 68 ms

session_models is a populated array on every conversation row, and the median grouped call is 68 ms against the before leg's 177 ms, so the LATERAL join did not cost latency

  1. The same window without grouping, for contrast
curl -s "$P/spend/logs/ui?page=1&page_size=50&start_date=$START&end_date=$END&sort_by=startTime&sort_order=desc" -H "Authorization: Bearer $K"
HTTP 200 | total: 201 | total_pages: 5 | page: 1 | page_size: 50 | len(data): 50
  row01: {"session_id": "lit6695-session-small-4", "model": "anthropic/claude-haiku-4-5"}
  row02: {"session_id": "lit6695-session-small-4", "model": "openai/gpt-5.4-nano"}
  row03: {"session_id": "lit6695-session-small-4", "model": "openai/gpt-5.4-nano"}
  row04: {"session_id": "lit6695-session-small-4", "model": "anthropic/claude-haiku-4-5"}
  row05: {"session_id": "lit6695-session-mid-72", "model": "anthropic/claude-haiku-4-5"}
  row06: {"session_id": "lit6695-session-mid-72", "model": "openai/gpt-5.4-nano"}
one row per call, 201 = the 196 loop calls plus 5 failed dashboard requests

Model rename or delete and access groups

  1. Create a model and a unified access group naming it
curl -s -X POST $P/model/new -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"model_name":"lit6695-rename-me","litellm_params":{"model":"openai/gpt-5.4-nano","api_key":"os.environ/OPENAI_API_KEY"},"model_info":{"access_groups":["lit6695-legacy-group"]}}'
{"model_id":"7aae664e-a544-4435-99ee-ef5a3a1c85ce","model_name":"lit6695-rename-me", ...,"model_info":{"id":"7aae664e-a544-4435-99ee-ef5a3a1c85ce","db_model":false,"access_groups":["lit6695-legacy-group"]}, ...}   HTTP 200

curl -s -X POST $P/v1/access_group -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"access_group_name":"lit6695-unified-group","access_model_names":["lit6695-rename-me"]}'
{"access_group_id":"67e8737e-1f5c-4280-a45e-23d8a7e9a4d3","access_group_name":"lit6695-unified-group","description":null,"access_model_names":["lit6695-rename-me"],"access_mcp_server_ids":[],"access_agent_ids":[],"assigned_team_ids":[],"assigned_key_ids":[], ...}   HTTP 201

curl -s $P/access_group/lit6695-legacy-group/info -H "Authorization: Bearer $K"
{"access_group":"lit6695-legacy-group","model_names":["lit6695-rename-me"],"deployment_count":1,"spend":0.0,"budget":null}   HTTP 200
  1. Rename it from the UI: http://localhost:43858/models-and-endpoints/, open the lit6695-rename-me row, Edit Settings, set Model Name to lit6695-renamed, Save Changes
PATCH http://localhost:29713/model/7aae664e-a544-4435-99ee-ef5a3a1c85ce/update  ->  HTTP 200
request body: {"model_name":"lit6695-renamed","litellm_params":{...,"model":"openai/gpt-5.4-nano","tags":[],"guardrails":[]},"model_info":{"id":"7aae664e-a544-4435-99ee-ef5a3a1c85ce","db_model":true,"blocked":false,"access_groups":["lit6695-legacy-group"], ...}}

Screenshots a4_s3_edit_form.png, a4_s3_rename_result.png

  1. The unified access group follows the new name, and so does everything else
curl -s $P/v1/access_group -H "Authorization: Bearer $K"
[{"access_group_name": "lit6695-unified-group", "access_model_names": ["lit6695-renamed"]}]

curl -s $P/access_group/lit6695-legacy-group/info -H "Authorization: Bearer $K"
{"access_group":"lit6695-legacy-group","model_names":["lit6695-renamed"],"deployment_count":1,"spend":0.0,"budget":null}   HTTP 200

curl -s "$P/model/info?litellm_model_id=7aae664e-a544-4435-99ee-ef5a3a1c85ce" -H "Authorization: Bearer $K"     (both workers, 8s apart, 8 polls)
poll 1: model/info=lit6695-renamed | v1/models(lit6695)=lit6695-renamed
...
poll 8: model/info=lit6695-renamed | v1/models(lit6695)=lit6695-renamed

curl -s -X POST $P/v1/chat/completions -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"model":"lit6695-renamed","messages":[{"role":"user","content":"hi"}],"max_tokens":5}'
{"id":"chatcmpl-EJuBLQF6wPJlXmg5PeV1eujNlFQRe","created":1788412903,"model":"lit6695-renamed","object":"chat.completion","choices":[{"finish_reason":"length","index":0,"message":{"content":"Hi!","role":"assistant", ...}}], ...}   HTTP 200
curl -s -X POST $P/v1/chat/completions -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"model":"lit6695-rename-me","messages":[{"role":"user","content":"hi"}],"max_tokens":5}'
{"error":{"message":"/chat/completions: Invalid model name passed in model=lit6695-rename-me. Call `/v1/models` to view available models for your key.", ...}}   HTTP 400
curl -s -X POST $P/v1/chat/completions -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"model":"lit6695-unified-group","messages":[{"role":"user","content":"hi"}],"max_tokens":5}'
{"error":{"message":"/chat/completions: Invalid model name passed in model=lit6695-unified-group. Call `/v1/models` to view available models for your key.", ...}}   HTTP 400

The deployment-derived group (lit6695-legacy-group) and the unified access group both read lit6695-renamed, and a call against the new name is served

  1. Rename through Terraform (litellm_model resource, model_name from TF_VAR_model_name) after both workers see the first apply's model
TF_VAR_model_name=lit6695-tf-model terraform apply -auto-approve
litellm_model.renamed: Creation complete after 1s [id=6e4f8801-bbe7-4dd7-97fc-bb51cdbf35f7]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

curl -s -X POST $P/v1/access_group -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"access_group_name":"lit6695-tf-group","access_model_names":["lit6695-tf-model"]}'
{"access_group_id":"b4f15350-6a81-43bf-ac7e-d694fc7f3703","access_group_name":"lit6695-tf-group","access_model_names":["lit6695-tf-model"], ...}   HTTP 201

TF_VAR_model_name=lit6695-tf-renamed terraform plan
  # litellm_model.renamed will be updated in-place
  ~ resource "litellm_model" "renamed" {
        id                                 = "6e4f8801-bbe7-4dd7-97fc-bb51cdbf35f7"
      ~ model_name                         = "lit6695-tf-model" -> "lit6695-tf-renamed"
        # (20 unchanged attributes hidden)
    }
Plan: 0 to add, 1 to change, 0 to destroy.

TF_VAR_model_name=lit6695-tf-renamed terraform apply -auto-approve
litellm_model.renamed: Modifications complete after 1s [id=6e4f8801-bbe7-4dd7-97fc-bb51cdbf35f7]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

curl -s "$P/model/info?litellm_model_id=6e4f8801-bbe7-4dd7-97fc-bb51cdbf35f7" -H "Authorization: Bearer $K"   (8 polls, 0s to 56s after the apply)
poll 1 (0s after apply):  model/info=lit6695-tf-renamed | v1/models=lit6695-renamed,lit6695-tf-renamed
poll 2 (8s after apply):  model/info=lit6695-tf-renamed | v1/models=lit6695-renamed,lit6695-tf-renamed
poll 3 (16s after apply): model/info=lit6695-tf-renamed | v1/models=lit6695-renamed,lit6695-tf-renamed
poll 4 (24s after apply): model/info=lit6695-tf-renamed | v1/models=lit6695-renamed,lit6695-tf-renamed
poll 5 (32s after apply): model/info=lit6695-tf-renamed | v1/models=lit6695-renamed,lit6695-tf-renamed
poll 6 (40s after apply): model/info=lit6695-tf-renamed | v1/models=lit6695-renamed,lit6695-tf-renamed
poll 7 (48s after apply): model/info=lit6695-tf-renamed | v1/models=lit6695-renamed,lit6695-tf-renamed
poll 8 (56s after apply): model/info=lit6695-tf-renamed | v1/models=lit6695-renamed,lit6695-tf-renamed

for i in $(seq 1 20); do curl -s "$P/v1/models" -H "Authorization: Bearer $K" | ... ; done | sort | uniq -c
  20 lit6695-renamed,lit6695-tf-renamed

curl -s $P/v1/access_group -H "Authorization: Bearer $K"
[{"access_group_name": "lit6695-tf-group", "access_model_names": ["lit6695-tf-renamed"]}, {"access_group_name": "lit6695-unified-group", "access_model_names": ["lit6695-renamed"]}]

curl -s -X POST $P/v1/chat/completions ... -d '{"model":"lit6695-tf-renamed", ...}'
{"id":"chatcmpl-EJvTQHs9MDdDnYkTlOmFTHvxMWnmj","created":1788417868,"model":"lit6695-tf-renamed","object":"chat.completion", ...}   HTTP 200
curl -s -X POST $P/v1/chat/completions ... -d '{"model":"lit6695-tf-model", ...}'
{"error":{"message":"/chat/completions: Invalid model name passed in model=lit6695-tf-model. Call `/v1/models` to view available models for your key.", ...}}   HTTP 400

The terraform rename reaches the proxy on the first poll, both workers agree across 20 consecutive /v1/models reads, the tf access group follows the new name, and only the new name serves traffic

  1. Delete the model renamed in the UI; the group drops the name
curl -s -X POST $P/model/delete -H "Authorization: Bearer $K" -H 'Content-Type: application/json' -d '{"id":"7aae664e-a544-4435-99ee-ef5a3a1c85ce"}'
{"message":"Model: 7aae664e-a544-4435-99ee-ef5a3a1c85ce deleted successfully"}   HTTP 200

curl -s $P/v1/access_group -H "Authorization: Bearer $K"
[{"access_group_name": "lit6695-tf-group", "access_model_names": ["lit6695-tf-renamed"]}, {"access_group_name": "lit6695-unified-group", "access_model_names": []}]

curl -s $P/access_group/lit6695-legacy-group/info -H "Authorization: Bearer $K"
{"detail":{"error":"Access group 'lit6695-legacy-group' not found"}}   HTTP 404

curl -s $P/model/info -H "Authorization: Bearer $K"     (lit6695 entries left, once the workers settle)
['lit6695-tf-renamed']
  1. Sibling case: two deployments share the name lit6695-shared, a group names it, one deployment is renamed and the other deleted
POST $P/model/new {"model_name":"lit6695-shared","litellm_params":{"model":"openai/gpt-5.4-nano", ...}}      -> 7ff9b3ce-7e06-4a4d-a14f-a43e17a46a34
POST $P/model/new {"model_name":"lit6695-shared","litellm_params":{"model":"anthropic/claude-haiku-4-5", ...}} -> 2aa1e9be-3abb-4e69-8505-3d2f7d465748

curl -s -X POST $P/v1/access_group ... -d '{"access_group_name":"lit6695-shared-group","access_model_names":["lit6695-shared"]}'
{"access_group_id":"4b3f71b2-d070-483d-99a2-dd9048d99e03","access_group_name":"lit6695-shared-group","access_model_names":["lit6695-shared"], ...}   HTTP 201

PATCH $P/model/2aa1e9be-3abb-4e69-8505-3d2f7d465748/update {"model_name":"lit6695-shared-b"}   HTTP 200  (model_name now: lit6695-shared-b)
curl -s $P/v1/access_group ...   {"access_group_name": "lit6695-shared-group", "access_model_names": ["lit6695-shared", "lit6695-shared-b"]}

POST $P/model/delete {"id":"7ff9b3ce-7e06-4a4d-a14f-a43e17a46a34"}
{"message":"Model: 7ff9b3ce-7e06-4a4d-a14f-a43e17a46a34 deleted successfully"}   HTTP 200
curl -s $P/v1/access_group ...   {"access_group_name": "lit6695-shared-group", "access_model_names": ["lit6695-shared-b"]}
curl -s $P/model/info ...        ['lit6695-tf-renamed', 'lit6695-shared-b']

curl -s -X POST $P/v1/chat/completions ... -d '{"model":"lit6695-shared", ...}'
{"error":{"message":"/chat/completions: Invalid model name passed in model=lit6695-shared. Call `/v1/models` to view available models for your key.", ...}}   HTTP 400
curl -s -X POST $P/v1/chat/completions ... -d '{"model":"lit6695-shared-b", ...}'
{"id":"chatcmpl-fd420d58-9bb6-4c3b-b1c4-8a6d6c147ce5","created":1788418005,"model":"lit6695-shared-b","object":"chat.completion", ...}   HTTP 200

While one deployment still answers to lit6695-shared the group holds both names, and once that deployment is gone the group holds only lit6695-shared-b. The /model/info and /v1/models reads settle about 20 seconds after each write, so the numbers above are the settled ones

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • Without Redis, other proxy workers and pods keep serving the old access-group membership for up to 10 minutes (DEFAULT_ACCESS_GROUP_CACHE_TTL) after a rename; only the worker that handled the rename invalidates its cache immediately
  • The access-group rewrite runs after the model row is written and not in the same transaction, so if it fails the model row is already renamed or deleted while the group still lists the old name; editing the group repairs it
  • After a rename or a delete, /model/info and /v1/models can keep serving the old name for roughly 20 seconds until every worker's router refreshes; the after-leg numbers below are the settled reads on a two-worker proxy

Low

  • POST /key/update with organization_id: "" now detaches the key from its org, matching the edit form's Clear, where the base returned a foreign-key 400
  • The edit form's Clear sends an explicit null, so a client that omits organization_id entirely still leaves the key's org untouched
  • POST /model/update with a different model_name now renames the deployment, which docs/proxy/model_management.md still describes as changing only litellm_params or model_info; a docs update follows once this merges
  • POST /model/update honors model_name only for models without a team
  • A conversation that used several models shows a comma list and no provider logo; the list holds at most 10 distinct models, truncates each name at 256 characters, and ends in , ... when the conversation used more than 10
  • MCP tool calls take slots in that 10-entry list under their MCP: <tool> names, so a conversation with many distinct tools can push model names past the cap; the trailing , ... still says the list was cut
  • "Still in use" means another database row or a config-defined deployment carries the old name
  • Unrelated to this change, the key edit form's Organization picker opens on "All Organizations" even for a key that already has one, so clearing it means picking an organization first; the diff here only touches what Clear sends, and that prefill gap is present on the base too

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@devin-ai-integration devin-ai-integration Bot added the risk:high Sensitive, broad, or high-risk change label Sep 2, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

PR #39436 labeled risk:high (17 files, 1,212 additions+deletions, touches key/model management and spend endpoints). No enterprise label, so Linear routing was skipped. #39436

@codspeed

codspeed Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fix_rc2_ui_bug_batch (7804574) with litellm_internal_staging (291d02f)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (ff17e8b) during the generation of this report, so 291d02f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@greptile-apps

greptile-apps Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR fixes cleared organization handling, conversation-level Request Logs metadata, and access-group synchronization during model rename and deletion

  • Normalizes cleared organization IDs across key creation and editing
  • Adds bounded session model aggregation and conversation-aware Request Logs rendering
  • Keeps access-group model names synchronized with deployment lifecycle changes
  • Persists model renames through the legacy model update endpoint

Confidence Score: 5/5

The PR appears safe to merge

No blocking failure remains

Important Files Changed

Filename Overview
litellm/proxy/_types.py Normalizes empty organization IDs to unset values for key generation and update requests
litellm/proxy/spend_tracking/spend_management_endpoints.py Adds capped per-session model aggregation while preserving non-MCP representative selection across all matching rows
ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.tsx Renders conversation-level type counts, spend, and model lists from server aggregates
litellm/proxy/management_endpoints/model_management_endpoints.py Synchronizes access groups after model rename or deletion and persists eligible legacy-endpoint renames
litellm/proxy/management_helpers/access_group_model_sync.py Rewrites access-group model arrays while retaining names still backed by database or config deployments

Reviews (8): Last reviewed commit: "fix(ui): send an explicit null when the ..." | Re-trigger Greptile

@codecov

codecov Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

A worker whose router has not polled the database yet still lists a sibling under its old
name, so a delete or rename handled there kept the stale name in every access group. Only
config-sourced deployments count as router backing now; db models are counted in the table.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 3, 2026
…nversation

A conversation that straddles the bounded page window can be represented by one of its MCP
rows, which showed a plain MCP badge and hid the session counts. The badge now reads the
server aggregates whenever the conversation has more than one call.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 3, 2026
yassin-berriai and others added 3 commits September 3, 2026 01:32
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ep the conversation badge for MCP representatives

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ mateo-berri
❌ yassin-berriai
You have signed the CLA already but the status is still pending? Let us recheck it.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

@greptileai

@veria-ai

veria-ai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

yassin-berriai and others added 2 commits September 3, 2026 01:58
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

@greptileai

yassin-berriai and others added 2 commits September 3, 2026 02:48
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 3, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Cleared org not removed on edit
    • Changed handleOrganizationChange to write null instead of undefined on clear so JSON.stringify keeps the field and /key/update actually clears the stored organization.

Create PR

Or push these changes by commenting:

@cursor push 13c5fbb0fe
Preview (13c5fbb0fe)
diff --git a/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx b/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
--- a/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
+++ b/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
@@ -303,8 +303,11 @@
     }
   };
 
-  const handleOrganizationChange = (setField: (value: string | undefined) => void, orgId: string | undefined) => {
-    setField(orgId || undefined);
+  const handleOrganizationChange = (
+    setField: (value: string | null | undefined) => void,
+    orgId: string | undefined,
+  ) => {
+    setField(orgId || null);
     setSelectedOrganizationId(orgId || null);
     form.setValue("team_id", undefined);
   };

You can send follow-ups to the cloud agent here.

…nization

Clearing the Organization picker in the key edit form wrote undefined into
the form value, and JSON.stringify drops undefined-valued keys, so
/key/update never saw the field and the key kept its old organization.
Writing null instead survives serialization, and the backend's
model_dump(exclude_unset=True) preserves it, so the column is set to NULL.
@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 3, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7804574. Configure here.

@yassin-berriai
yassin-berriai merged commit 34d4f7f into litellm_internal_staging Sep 3, 2026
141 of 146 checks passed
@yassin-berriai
yassin-berriai deleted the litellm_fix_rc2_ui_bug_batch branch September 3, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:high Sensitive, broad, or high-risk change run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants