Skip to content

chore(router): simplify unknown-model error message construction - #31566

Merged
yuneng-berri merged 2 commits into
BerriAI:litellm_yj_june29from
stuxf:litellm_router_unknown_model_error_cleanup
Jun 29, 2026
Merged

chore(router): simplify unknown-model error message construction#31566
yuneng-berri merged 2 commits into
BerriAI:litellm_yj_june29from
stuxf:litellm_router_unknown_model_error_cleanup

Conversation

@stuxf

@stuxf stuxf commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Changes

The unknown-model error message in Router is already fully built by the f-string interpolation, so the trailing .format() call on the resulting string was redundant. This removes it and adds a regression test that the message renders the model name verbatim.

Type

🧹 Refactoring

The error string is already produced by the f-string interpolation; the
trailing .format() call on it was redundant. Add a regression test that
the message renders the model name verbatim.
@greptile-apps

greptile-apps Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR simplifies Router unknown-model error message construction. The main changes are:

  • Removed redundant .format() calls after f-string interpolation in litellm/router.py
  • Added a focused regression test for model names containing Python format-field syntax
  • Confirmed the unknown-model message preserves the caller-supplied model name literally

Confidence Score: 5/5

The change is narrowly scoped to redundant string formatting removal and is covered by a focused regression test.

The implementation preserves the existing constructed error message while eliminating the extra formatting step, and the added test exercises the relevant edge case for literal model names.

T-Rex T-Rex Logs

What T-Rex did

  • The before-revision repro for the router-unknown-model message finished with EXIT_CODE: 0.
  • The after-revision repro finished with EXIT_CODE: 0 and produced an improved head error string that includes You passed in model=ghost with literal_model_contained: True and padding_run_detected flags: False.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "chore(router): simplify unknown-model er..." | Re-trigger Greptile

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

get_model_list always returns a list, never None, so the is-None branch
could not execute. Collapse to the single reachable message.
@yuneng-berri
yuneng-berri changed the base branch from litellm_internal_staging to litellm_yj_june29 June 29, 2026 18:55
@yuneng-berri
yuneng-berri merged commit f042919 into BerriAI:litellm_yj_june29 Jun 29, 2026
75 checks passed
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