6 views
-/https://github.com/berriai/litellm/issues/30742
GitHub · issue

#30742 [Bug]: Bedrock Converse map_openai_params uses if instead of elif causing unnecessary checks

  • State: open
  • Author: @FadelT
  • Labels: llm translation

### What happened?

In `litellm/llms/bedrock/chat/converse_transformation.py`, the `map_openai_params` method (lines 904-968) uses repeated `if param ==` statements instead of `elif` when mapping OpenAI parameters to Bedrock Converse format.

This causes: 1. **Performance issue**: Every parameter is checked against ALL 15+ conditions even after finding a match 2. **Potential correctness issue**: A parameter could theoretically match multiple branches (though currently unlikely)

**Comparison**: - `litellm/llms/anthropic/chat/transformation.py` correctly uses `elif` for the same pattern (line 1429+) - All other provider adapters use `elif` for mutually exclusive parameter mapping

**Example** (lines 913-923): ```python if param == "max_tokens" or param == "max_completion_tokens": optional_params["maxTokens"] = value if param == "stream": optional_params["stream"] = value if param == "stop": # ... ```

Should be: ```python if param == "max_tokens" or param == "max_completion_tokens": optional_params["maxTokens"] = value elif param == "stream": optional_params["stream"] = value elif param == "stop": # ... ```

**Note**: Lines 954, 958 already use `elif` (for `r…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h3m12s ago — entered · #import:https:::github.com:berriai:litellm post #2811
28409 requires changes across shared message-processing and token-counting paths, with compatibility decisions and broader regression coverage; 30742 is a localized control-flow cleanup with minimal behavioral scope.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search