backend/utils/config_utils.py:41-49:
def get_model_name_from_config(model_config: Dict[str, Any]) -> str:
"""Get model name from model id"""
if model_config is None:
return ""
model_repo = model_config["model_repo"]
model_name = model_config["model_name"]
if not model_repo:
return model_name
return f"{model_repo}/{model_name}"
The function defends against None but not against partial dicts. Two callers — backend/utils/llm_utils.py:77 (OpenAIModel(model_id=get_model_name_from_config(llm_model_config) if llm_model_config else "")) and backend/utils/memory_utils.py:47, 55 — pass dicts that come straight from tenant_config_manager.get_model_config(). That manager returns default={} whenever the model id can't be parsed (config_utils.py:101), which means a sneaky path exists where you get an {} dict rather than None, and accessing model_config["model_repo"] then raises KeyError.
Concrete repro: configure a tenant with a non-numeric LLM_ID. get_model_config returns default which the caller may have passed as {} or as a partial dict like {"model_name": "x"}. The next call into get_model_name_from_config blows up.
Suggested fix
def get_model_name_from_config(model_config: Dict[str, Any]) -> str:
if not model_config:
return ""
model_repo = model_config.get("model_repo") or ""
model_name = model_config.get("model_name") or ""
if not model_repo:
return model_name
return f"{model_repo}/{model_name}"
Severity: Medium. The crash propagates up and the user sees a 500.
backend/utils/config_utils.py:41-49:The function defends against
Nonebut not against partial dicts. Two callers —backend/utils/llm_utils.py:77(OpenAIModel(model_id=get_model_name_from_config(llm_model_config) if llm_model_config else "")) andbackend/utils/memory_utils.py:47, 55— pass dicts that come straight fromtenant_config_manager.get_model_config(). That manager returnsdefault={}whenever the model id can't be parsed (config_utils.py:101), which means a sneaky path exists where you get an{}dict rather thanNone, and accessingmodel_config["model_repo"]then raisesKeyError.Concrete repro: configure a tenant with a non-numeric
LLM_ID.get_model_configreturnsdefaultwhich the caller may have passed as{}or as a partial dict like{"model_name": "x"}. The next call intoget_model_name_from_configblows up.Suggested fix
Severity: Medium. The crash propagates up and the user sees a 500.