fix(proxy): decrypt the stored model before the cost-map lookup

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
ryan 2026-09-19 09:45:27 +00:00
parent de86d2fdbe
commit b931af9a2a
2 changed files with 28 additions and 1 deletions

View file

@ -877,7 +877,9 @@ def _ptu_priced_deployment(model_params: Deployment) -> Deployment:
def _cost_map_entry(db_model: Deployment, incoming_model_info: Mapping[str, object]) -> Mapping[str, object]:
base_model: Final = incoming_model_info.get("base_model")
lookup: Final = base_model if isinstance(base_model, str) else db_model.litellm_params.model
lookup: Final = base_model if isinstance(base_model, str) else _decrypted_model(db_model.litellm_params.model)
if lookup is None:
return MappingProxyType({})
try:
return MappingProxyType(dict(litellm.get_model_info(model=lookup)))
except Exception:

View file

@ -4160,6 +4160,31 @@ class TestModelInfoCostMapEchoFilter:
assert not frozenset(info).intersection(frozenset(entry) - frozenset(("mode",)))
assert info["base_model"] == "azure/gpt-5.6"
def test_encrypted_stored_model_is_decrypted_for_the_lookup(self, monkeypatch):
import litellm
from litellm.proxy.management_endpoints.model_management_endpoints import update_db_model
from litellm.types.router import Deployment, LiteLLM_Params, ModelInfo
monkeypatch.setenv("LITELLM_SALT_KEY", "sk-1234")
entry = litellm.get_model_info("openai/gpt-5.6")
db_model = Deployment(
model_name="gpt-5.6",
litellm_params=LiteLLM_Params(model=encrypt_value_helper(value="openai/gpt-5.6")),
model_info=ModelInfo(id="dep-echo-7", mode="chat"),
)
echo = {**entry, "id": "dep-echo-7", "db_model": True, "access_groups": ["prod"]}
result = update_db_model(
db_model=db_model,
updated_patch=updateDeployment(model_info=ModelInfo(**echo)),
)
info = json.loads(result["model_info"])
assert not frozenset(info).intersection(frozenset(entry) - frozenset(("mode",)))
assert info["mode"] == "chat"
assert info["access_groups"] == ["prod"]
class TestUpdateDBModelClearCacheControlInjectionPoints:
def test_explicit_null_removes_stored_injection_points(self):