Skip to content

Fix health check stripping bedrock/ prefix from model name#24716

Closed
joaquinhuigomez wants to merge 3 commits intoBerriAI:mainfrom
joaquinhuigomez:fix/bedrock-health-check-prefix
Closed

Fix health check stripping bedrock/ prefix from model name#24716
joaquinhuigomez wants to merge 3 commits intoBerriAI:mainfrom
joaquinhuigomez:fix/bedrock-health-check-prefix

Conversation

@joaquinhuigomez
Copy link
Copy Markdown
Contributor

Fixes #24694

_update_litellm_params_for_health_check strips the bedrock/ prefix from the model name to extract the base model, but never re-adds it when assigning back to litellm_params["model"]. This causes get_llm_provider() to fail for models not in the cost map since there's no provider prefix to split on.

Re-added the bedrock/ prefix after processing so the model name retains its provider routing information.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Mar 28, 2026 1:01pm

Request Review

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented Mar 28, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing joaquinhuigomez:fix/bedrock-health-check-prefix (dab474b) with main (fe080a8)

Open in CodSpeed

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 28, 2026

Greptile Summary

This PR fixes a one-line bug in _update_litellm_params_for_health_check where the bedrock/ provider prefix was stripped from the model name but never re-added, causing get_llm_provider() to fail for Bedrock models not present in the cost map.

Key changes:

  • litellm/proxy/health_check.py (line 328): changed litellm_params[\"model\"] = modellitellm_params[\"model\"] = \"bedrock/\" + model, correctly restoring the provider prefix after AWS-region segments are filtered out.
  • tests/litellm_utils_tests/test_health_check.py: all Bedrock-related assertions updated from the former (broken) unprefixed expectations to the correct bedrock/<model> expectations. The test modifications strengthen coverage — they now assert the corrected behavior rather than the previous bug. All tests remain pure mock/unit tests with no real network calls.

Confidence Score: 5/5

This PR is safe to merge — it is a minimal, targeted bug fix with comprehensive test coverage.

The change is a single-line fix that corrects a clear regression (stripped provider prefix). All existing test assertions have been properly updated to reflect the corrected behavior, not weakened to mask a regression. No new network calls, no architectural changes, no backwards-incompatible behavior for non-Bedrock providers.

No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/health_check.py One-line fix: re-adds bedrock/ prefix after region-stripping, preventing get_llm_provider() failures for models not in the cost map.
tests/litellm_utils_tests/test_health_check.py All Bedrock-related assertions updated from the old (stripped) behavior to the corrected (prefix-preserved) behavior; also includes minor Black-style reformatting.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["litellm_params['model']"] --> B{starts with bedrock/?}
    B -- No --> G[Return params unchanged]
    B -- Yes --> C[Strip 'bedrock/' prefix]
    C --> D[Split remaining path by '/']
    D --> E["Filter out AWS region segments\n(e.g. us-west-2, eu-central-1)"]
    E --> F["Re-join parts and prepend 'bedrock/'"]
    F --> H["litellm_params['model'] = 'bedrock/' + filtered_model"]
    H --> I[Return params]
    G --> I
Loading

Reviews (3): Last reviewed commit: "Fix black formatting in test_health_chec..." | Re-trigger Greptile


model = "/".join(filtered_parts)
litellm_params["model"] = model
litellm_params["model"] = "bedrock/" + model
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.

P1 Existing tests expect old (no-prefix) behavior and would fail

The fix correctly re-adds bedrock/ prefix, but all existing Bedrock-related assertions in tests/litellm_utils_tests/test_health_check.py encode the old (pre-fix) behavior and would now fail:

  • Line 348: assert updated_params["model"] == "anthropic.claude-3-7-sonnet-20250219-v1:0" — would now get "bedrock/anthropic.claude-3-7-sonnet-20250219-v1:0"
  • Line 357: assert updated_params["model"] == "us.anthropic.claude-3-5-sonnet-20240620-v1:0" — same issue
  • Line 365: assert updated_params["model"] == "anthropic.claude-3-5-sonnet-20240620-v1:0" — same issue
  • Lines 395, 403, 412, 424, 432, 442, 454, 463, 473 — all assert model names without the bedrock/ prefix

Every assertion in the "Bedrock" section of test_update_litellm_params_for_health_check needs to be updated to reflect the new expected behavior, e.g.:

# Before (old broken behavior)
assert updated_params["model"] == "anthropic.claude-3-7-sonnet-20250219-v1:0"

# After (correct behavior, matches the fix)
assert updated_params["model"] == "bedrock/anthropic.claude-3-7-sonnet-20250219-v1:0"

Similarly, sub-prefix variants like "us.anthropic...", route variants like "converse/...", and handler variants like "llama/arn:..." all need the bedrock/ prepended in their assertions to match the fixed output.

Rule Used: What: Ensure that any PR claiming to fix an issue ... (source)

@joaquinhuigomez
Copy link
Copy Markdown
Contributor Author

Closing — lint noise is making this hard to review. Happy to revisit.

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.

[Bug]: Health check strips bedrock/ prefix causing provider identification failure for models not in cost map

1 participant