{"record":{"id":"ed545d666e478e58","repo":"BerriAI/litellm","slug":"each-entry-in-fallback-sap-modules-must-include","errorCode":null,"errorMessage":"Each entry in `fallback_sap_modules` must include a 'model' key.","messagePattern":"Each entry in `fallback_sap_modules` must include a 'model' key\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"litellm/llms/sap/chat/transformation.py","lineNumber":348,"sourceCode":"                stream_config[\"chunk_size\"] = stream_options[\"chunk_size\"]\n            if \"delimiters\" in stream_options:\n                stream_config[\"delimiters\"] = stream_options[\"delimiters\"]\n\n        optional_params.pop(\"tool_choice\", None)\n\n        modules: Final = [\n            self._build_prompt_module(\n                model_name=model,\n                template_messages=template,\n                params=dict(optional_params),\n            )\n        ]\n\n        for modules_dict in fallback_modules:\n            modules_dict = dict(modules_dict)\n            fallback_model = modules_dict.pop(\"model\", None)\n            if fallback_model is None:\n                raise ValueError(\"Each entry in `fallback_sap_modules` must include a 'model' key.\")\n            fallback_model = fallback_model.removeprefix(\"sap/\")\n            fallback_template = modules_dict.pop(\"messages\", [])\n\n            modules.append(\n                self._build_prompt_module(\n                    model_name=fallback_model,\n                    template_messages=fallback_template,\n                    params=modules_dict,\n                )\n            )\n\n        config_payload: Final[dict[str, Any]] = {\n            \"modules\": modules if len(modules) > 1 else modules[0],\n        }\n        if stream_config:\n            config_payload[\"stream\"] = stream_config\n\n        request_body: Final[dict[str, Any]] = {\"config\": config_payload}","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/sap/chat/transformation.py#L330-L366","documentation":"When building the SAP module chain, each entry in the fallback_sap_modules list must name the fallback model via a 'model' key; LiteLLM pops 'model' (and 'messages') from each dict to build a fallback prompt module. If 'model' is absent or None, this ValueError is raised before the request is sent.","triggerScenarios":"Calling a sap/ model with fallback_sap_modules=[{'messages': [...]}] or any entry whose 'model' key is missing/None - e.g. only template messages or params were supplied for the fallback.","commonSituations":"Reusing fallback_configs written for OpenAI-style fallbacks (which use 'model' at a different nesting level); dynamically building fallback entries where the model key is conditionally set; typos like 'model_name' instead of 'model'.","solutions":["Add 'model' to every fallback entry: fallback_sap_modules=[{'model': 'sap/gpt-4o', 'messages': [...]}].","If the model string includes the 'sap/' prefix it is stripped automatically, but the key itself must be named exactly 'model'.","Validate the list shape at startup: assert all('model' in entry for entry in fallback_sap_modules)."],"exampleFix":"# before\nfallback_sap_modules=[{'messages': [{'role': 'user', 'content': 'hi'}]}]\n# after\nfallback_sap_modules=[{'model': 'sap/gpt-4o', 'messages': [{'role': 'user', 'content': 'hi'}]}]","handlingStrategy":"validation","validationCode":"def validate_fallbacks(entries: list[dict]) -> list[dict]:\n    for i, entry in enumerate(entries):\n        if not entry.get('model'):\n            raise ValueError(f'fallback_sap_modules[{i}] is missing required key \"model\"')\n    return entries","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Type fallback entries as TypedDict with required 'model' so static checkers catch omissions.","Build fallback entries through one factory that always sets the model key."],"tags":["sap","fallback-modules","validation","required-field"],"backgroundTag":"missing-required-parameter","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}