Skip to content

fix(credentials): keep credential labels and edits consistent across UI, API, and replicas - #45835

Merged
yuneng-berri merged 4 commits into
mainfrom
litellm_fix_b94d387
Oct 10, 2026
Merged

yuneng-berri merged 4 commits into
mainfrom
litellm_fix_b94d387

Conversation

@yuneng-berri

@yuneng-berri yuneng-berri commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Editing a credential could save onto a different credential
  • An edit inside the read replica lag window undid a recent relabel or key rotation
  • POST could shadow a config.yaml credential with a DB copy
  • Labels accepted invisible and text-reversing characters
  • UI and API disagreed on how long a label can be
  • Models pages showed only the label, hiding which credential is used

How it solves it:

  • The credential modal keeps top-level fields and stored values separate
  • PATCH merges onto the writer's row instead of the replica's
  • POST answers 409 for a credential name defined in config
  • The server alone validates labels, and the UI shows its error
  • Models table and model detail show the credential name under its label, and the full name on hover
  • The credentials list shows Config or DB in a Source column, like the models table

Intentional product change: the dashboard no longer trims or length-checks the label before saving, so a label of only spaces now shows the server's "cannot be blank" error instead of clearing the label (clear it by emptying the field). POST /credentials with the name of a config.yaml credential now returns 409 instead of creating a DB copy that overrides it

User Flow

Before: an admin saves an untouched credential and the dashboard relabels a different one

  1. An older credential legacy-a (label "Legacy A") has stored values that happen to include credential_name: label-probe and display_name: Inner label
  2. The admin opens http://localhost:3005/models-and-endpoints/, clicks LLM Credentials, then Edit on "Legacy A"
  3. The dialog shows Credential Name label-probe and Display Name "Inner label"
  4. They click Update Credential without changing anything and see "Credential updated successfully"
  5. The browser sent PATCH /credentials/label-probe, and the list now shows label-probe relabeled "Inner label"

After: the same save stays on the credential the admin opened

  1. Same legacy-a credential with the same stored values
  2. The admin opens http://localhost:3006/models-and-endpoints/, clicks LLM Credentials, then Edit on "Legacy A"
  3. The dialog shows Credential Name legacy-a and Display Name "Legacy A"
  4. They click Update Credential without changing anything and see "Credential updated successfully"
  5. The browser sent PATCH /credentials/legacy-a, and label-probe is unchanged
Before After
before edit dialog after edit dialog
before list after save after list after save

Before: the models table names a credential only by its label, so a reader cannot tell which credential a model uses

  1. Credential proof-openai has the label "Relabeled" and model db-model uses it
  2. The admin opens http://localhost:3005/models-and-endpoints/ on the Deployed Models tab
  3. The Credentials column for db-model shows only "Relabeled"

After: the column shows the label with the credential name under it

  1. Same credential and model
  2. The admin opens http://localhost:3006/models-and-endpoints/ on the Deployed Models tab
  3. The Credentials column for db-model shows "Relabeled" with proof-openai beneath it in muted text. The model detail view, the model edit picker, and the "Using Existing Credential" dialog do the same
Before After
before models table after models table

Before: the credential list shows a config credential as editable after a POST shadowed it, and a stored Prod\u202eAI label (U+202E, right-to-left override) renders reversed as "ProdIA". After: the POST was refused, so cfg-openai still shows Config in the new Source column, and the reversing label was rejected

Before After
before credentials list after credentials list

Relevant issues

Follows up on #43148

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/unit/<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

Both proxies ran side by side against one local Postgres with separate databases, real OpenAI calls through openai/gpt-5.4-nano, and dotenv turned off so neither inherits stray env (LITELLM_MODE=PRODUCTION STORE_MODEL_IN_DB=True). Before is a worktree at the merge base on :4011, After is this branch on :4012, and the dashboard dev servers are :3005 and :3006

model_list:
  - model_name: cfg-model
    litellm_params:
      model: openai/gpt-5.4-nano
      litellm_credential_name: cfg-openai
  - model_name: db-model
    litellm_params:
      model: openai/gpt-5.4-nano
      litellm_credential_name: proof-openai
credential_list:
  - credential_name: cfg-openai
    credential_values:
      api_key: os.environ/PROOF_OPENAI_KEY
    credential_info:
      custom_llm_provider: openai
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

create-proof-openai.json is {"credential_name": "proof-openai", "display_name": "Original", "credential_values": {"api_key": "<real OpenAI key>", "api_base": "https://api.openai.com/v1"}, "credential_info": {"custom_llm_provider": "openai"}} and create-label-probe.json is the same shape for label-probe with only an api key. The proxy env carries no OPENAI_API_KEY, so a request can only succeed through a credential

For the replica case each proxy was stopped, its database was copied with CREATE DATABASE <db>_replica TEMPLATE <db>, and the proxy was restarted with DATABASE_URL_READ_REPLICA pointing at that copy. The copy never receives later writes, which is a replica stuck at the start of its lag window

Before (38d0333)

POST over a config.yaml credential

  1. curl -s -X POST localhost:4011/credentials -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"credential_name": "cfg-openai", "credential_values": {"api_key": "sk-not-a-real-key"}, "credential_info": {"custom_llm_provider": "openai"}}'

    {"success":true,"message":"Credential created successfully"}
    
  2. curl -s localhost:4011/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model": "cfg-model", "messages": [{"role": "user", "content": "Reply with the single word ok"}]}'

    401 litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key prov...
    

Invisible and text-reversing label characters

  1. curl -s -X PATCH localhost:4011/credentials/label-probe -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"display_name": "\u200b", "credential_info": {}}'

    {"success":true,"message":"Credential updated successfully"}
    
  2. curl -s -X PATCH localhost:4011/credentials/label-probe -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"display_name": "Prod\u202eAI", "credential_info": {}}'

    {"success":true,"message":"Credential updated successfully"}
    

    The credential list then renders it as "ProdIA" (see the credential list screenshot under User Flow)

Edit right after a relabel, with a lagging read replica

  1. curl -s -X PATCH localhost:4011/credentials/proof-openai -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"display_name": "Relabeled", "credential_info": {}}'

    {"success":true,"message":"Credential updated successfully"}
    
  2. curl -s -X PATCH localhost:4011/credentials/proof-openai -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"credential_values": {"api_base": "https://api.openai.com/v1/"}, "credential_info": {}}'

    {"success":true,"message":"Credential updated successfully"}
    
  3. psql -h 127.0.0.1 -p 55432 -U postgres -d proof_before -Atc "select display_name from \"LiteLLM_CredentialsTable\" where credential_name = 'proof-openai'"

    Original
    
  4. curl -s localhost:4011/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model": "db-model", "messages": [{"role": "user", "content": "Reply with the single word ok"}]}'

    ok
    

Saving a credential whose stored values reuse top-level names

  1. Follow the Before list under User Flow. The dialog for "Legacy A" shows label-probe, and Update Credential sends PATCH http://localhost:4011/credentials/label-probe (200), relabeling label-probe to "Inner label"

Models table credential column

  1. Open http://localhost:3005/models-and-endpoints/. The db-model row shows only "Relabeled" (screenshot under User Flow)

After (c9989b1)

POST over a config.yaml credential

  1. curl -s -X POST localhost:4012/credentials -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"credential_name": "cfg-openai", "credential_values": {"api_key": "sk-not-a-real-key"}, "credential_info": {"custom_llm_provider": "openai"}}'

    {"error":{"message":"Credential 'cfg-openai' is defined in config. Edit config.yaml to change it.","type":"validation_error","param":"credential_name","code":"409"}}
    
  2. curl -s localhost:4012/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model": "cfg-model", "messages": [{"role": "user", "content": "Reply with the single word ok"}]}'

    ok
    

Invisible and text-reversing label characters

  1. curl -s -X PATCH localhost:4012/credentials/label-probe -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"display_name": "\u200b", "credential_info": {}}'

    {"error":{"message":"display_name cannot contain control, formatting, or line separator characters.","type":"validation_error","param":"display_name","code":"400"}}
    
  2. curl -s -X PATCH localhost:4012/credentials/label-probe -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"display_name": "Prod\u202eAI", "credential_info": {}}'

    {"error":{"message":"display_name cannot contain control, formatting, or line separator characters.","type":"validation_error","param":"display_name","code":"400"}}
    

Edit right after a relabel, with a lagging read replica

  1. curl -s -X PATCH localhost:4012/credentials/proof-openai -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"display_name": "Relabeled", "credential_info": {}}'

    {"success":true,"message":"Credential updated successfully"}
    
  2. curl -s -X PATCH localhost:4012/credentials/proof-openai -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"credential_values": {"api_base": "https://api.openai.com/v1/"}, "credential_info": {}}'

    {"success":true,"message":"Credential updated successfully"}
    
  3. psql -h 127.0.0.1 -p 55432 -U postgres -d proof_after -Atc "select display_name from \"LiteLLM_CredentialsTable\" where credential_name = 'proof-openai'"

    Relabeled
    
  4. curl -s localhost:4012/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model": "db-model", "messages": [{"role": "user", "content": "Reply with the single word ok"}]}'

    ok
    

Saving a credential whose stored values reuse top-level names

  1. Follow the After list under User Flow. The dialog for "Legacy A" shows legacy-a, and Update Credential sends PATCH http://localhost:4012/credentials/legacy-a (200), leaving label-probe untouched

Models table credential column

  1. Open http://localhost:3006/models-and-endpoints/. The db-model row shows "Relabeled" with proof-openai under it (screenshot under User Flow)

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • Rows already holding bad labels or config shadows stay until edited
    • Labels with control characters remain stored as they are
    • DB copies of config credentials created before this PR remain

Low

  • Rejecting format characters also blocks emoji joined with U+200D
  • Vector store credential pickers still show only the label
  • Label error now appears as a toast, not inline in the field

…UI, API, and replicas

The credential modal flattened stored credential values into the same form object as the
credential's own name, label, and provider, so a stored value keyed credential_name or
display_name replaced the real one and the edit went to the wrong credential or relabeled it.
The modal now submits the top-level fields and credential_values separately

PATCH /credentials now reads the row it merges onto from the writer, so an edit inside the read
replica's lag window no longer writes back an older label or key

POST /credentials answers 409 for a name defined in config instead of creating a DB copy that
shadows it

display_name rules live on the server only. It rejects control, formatting, and line separator
characters, and the UI stops enforcing its own length check and shows the server's error

The models table, model detail view, and model edit picker show the credential's technical name
under its label whenever the two differ
@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The latest changes appear safe to merge; all three previous findings are addressed.

Summary

The latest commits address all three previous findings.

  • Credential edits stay on the credential the admin opened.
  • The credential API rejects config name collisions and hard-to-read labels.
  • Credential edits merge onto the writer’s current row.
  • Model screens show the credential name beneath its label.
  • The credential list shows whether each entry comes from config or the database.

No new actionable issues were found. Tests were inspected but not run.

Reviews (2) · Last reviewed commit: "test(credentials): unit-test label and p..." · Reviewed by Greptile

@codspeed

codspeed Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 31 untouched benchmarks


Comparing litellm_fix_b94d387 (4679fa1) with main (58808f5)1

Open in CodSpeed

Footnotes

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

@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The config marker sat under the credential name. The credentials table now has a Source column
with a Config or DB status badge, matching the Source column on the models table
…ull credential name on hover

Moves displayNameChange and initialFormValues out of the modal so their rules are unit tested,
keeps only the wiring cases in the modal's integration test, makes the label acceptance test
write through the real credentials repository, and adds the full credential name as a hover
title where the models pages truncate it
@yuneng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai please review the latest commits, which address all three findings from the previous pass.

@yuneng-berri
yuneng-berri enabled auto-merge (squash) October 10, 2026 23:09
@yuneng-berri
yuneng-berri merged commit b2cc5f2 into main Oct 10, 2026
92 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_fix_b94d387 branch October 10, 2026 23:26
yuneng-berri added a commit that referenced this pull request Oct 10, 2026
Backport #45835 from b2cc5f2

Keep RC provider support while adapting credential form callbacks and regression tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants