{"record":{"id":"fc8b2d317a627fec","repo":"BerriAI/litellm","slug":"prompt-id-is-required-for-dotprompt-manager","errorCode":null,"errorMessage":"prompt_id is required for dotprompt manager","messagePattern":"prompt_id is required for dotprompt manager","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/dotprompt/dotprompt_manager.py","lineNumber":124,"sourceCode":"        prompt_id: str | None,\n        prompt_spec: PromptSpec | None,\n        prompt_variables: dict | None,\n        dynamic_callback_params: StandardCallbackDynamicParams,\n        prompt_label: str | None = None,\n        prompt_version: int | None = None,\n    ) -> PromptManagementClient:\n        \"\"\"\n        Compile a .prompt file into a PromptManagementClient structure.\n\n        This method:\n        1. Loads the prompt template from the .prompt file (with optional version)\n        2. Renders it with the provided variables\n        3. Converts the rendered text into chat messages\n        4. Extracts model and optional parameters from metadata\n        \"\"\"\n\n        if prompt_id is None:\n            raise ValueError(\"prompt_id is required for dotprompt manager\")\n\n        try:\n            # Get the prompt template (versioned or base)\n            template: Final = self.prompt_manager.get_prompt(prompt_id=prompt_id, version=prompt_version)\n            if template is None:\n                version_str: Final = f\" (version {prompt_version})\" if prompt_version else \"\"\n                raise ValueError(f\"Prompt '{prompt_id}'{version_str} not found in prompt directory\")\n\n            # Render the template with variables (pass version for proper lookup)\n            rendered_content: Final = self.prompt_manager.render(\n                prompt_id=prompt_id,\n                prompt_variables=prompt_variables,\n                version=prompt_version,\n            )\n\n            # Convert rendered content to chat messages\n            messages: Final = self._convert_to_messages(rendered_content)\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/dotprompt/dotprompt_manager.py#L106-L142","documentation":"compile_prompt_helper in DotpromptManager requires a non-None prompt_id — the identifier that selects which .prompt file to load (normally extracted from the model string \"dotprompt/<prompt_id>\"). A None prompt_id raises this ValueError before any template lookup happens.","triggerScenarios":"Model string of exactly \"dotprompt/\" or \"dotprompt\" with no ID after the slash; calling compile_prompt_helper(prompt_id=None, ...) directly; routing code that splits the model name and passes an empty/None component.","commonSituations":"Dynamically building the model string from a variable that is empty for some requests; typos in proxy model aliases; custom routers that strip the suffix.","solutions":["Use the full model form: model=\"dotprompt/my_prompt\" (optionally \"dotprompt/my_prompt:variant\")","Log the model string before the call and fix the code path that produces an empty prompt ID","If calling the helper directly, always pass a concrete prompt_id string"],"exampleFix":"# before\nprompt_name = None  # lookup failed earlier\nresp = litellm.completion(model=f\"dotprompt/{prompt_name}\", ...)  # 'dotprompt/None' or missing id\n\n# after\nprompt_name = \"greeting\"\nassert prompt_name, \"prompt id must resolve before calling\"\nresp = litellm.completion(model=f\"dotprompt/{prompt_name}\", ...)","handlingStrategy":"validation","validationCode":"import re\n\nDOTPROMPT_MODEL = re.compile(r\"^dotprompt/([^:/]+)(?::([^/]+))?$\")\n\ndef parse_dotprompt_model(model: str) -> tuple[str, str | None] | None:\n    m = DOTPROMPT_MODEL.match(model or \"\")\n    return (m.group(1), m.group(2)) if m else None\n\n# before the call:\n# parsed = parse_dotprompt_model(model)\n# assert parsed and parsed[0], f\"model must be dotprompt/<prompt_id>, got {model!r}\"","typeGuard":"from typing import Any\n\ndef has_prompt_id(prompt_id: Any) -> bool:\n    \"\"\"compile_prompt_helper requires a concrete, non-empty id string.\"\"\"\n    return isinstance(prompt_id, str) and len(prompt_id) > 0","tryCatchPattern":null,"preventionTips":["Validate the dotprompt model string at request ingress (regex above)","Never build model names from unvalidated optional variables; default and assert them","Log model + prompt_id together so empty ids are obvious in traces"],"tags":["dotprompt","prompt-management","required-parameter","model-string"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}