{"record":{"id":"b771b1e3cc981325","repo":"BerriAI/litellm","slug":"prompt-prompt-id-version-str-not-found-avail","errorCode":null,"errorMessage":"Prompt '{prompt_id}'{version_str} not found. Available prompts: {available_prompts}","messagePattern":"Prompt '(.+?)'(.+?) not found\\. Available prompts: (.+?)","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/dotprompt/prompt_manager.py","lineNumber":210,"sourceCode":"        Args:\n            prompt_id: The ID of the prompt template to render\n            prompt_variables: Variables to substitute in the template\n            version: Optional version number. If provided, looks for {prompt_id}.v{version}\n\n        Returns:\n            The rendered prompt string\n\n        Raises:\n            KeyError: If prompt_id is not found\n            ValueError: If template rendering fails\n        \"\"\"\n        # Get the template (versioned or base)\n        template: Final = self.get_prompt(prompt_id=prompt_id, version=version)\n\n        if template is None:\n            available_prompts: Final = list(self.prompts.keys())\n            version_str: Final = f\" (version {version})\" if version else \"\"\n            raise KeyError(f\"Prompt '{prompt_id}'{version_str} not found. Available prompts: {available_prompts}\")\n\n        variables: Final = prompt_variables or {}\n\n        # Validate input variables against schema if defined\n        if template.input_schema:\n            self._validate_input(variables, template.input_schema)\n\n        try:\n            # Create Jinja2 template and render\n            jinja_template: Final = self.jinja_env.from_string(template.content)\n            rendered: Final = jinja_template.render(**variables)\n            return rendered\n        except Exception as e:\n            raise ValueError(f\"Error rendering template '{prompt_id}': {e}\")\n\n    def _validate_input(self, variables: dict[str, Any], schema: dict[str, Any]) -> None:\n        \"\"\"Basic validation of input variables against schema.\"\"\"\n        for field_name, field_type in schema.items():","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/dotprompt/prompt_manager.py#L192-L228","documentation":"PromptManager.render looks up the template with get_prompt(prompt_id, version); when no template is registered under that id (or that exact version), it raises KeyError including the id, the requested version, and the list of ids actually loaded. This is the manager's explicit not-found signal instead of a silent empty render. Note the directory loader swallows per-file errors, so a prompt whose file failed to parse simply never registers and shows up only through this error.","triggerScenarios":"render('summarize') before any load call registered that id; render('summarize', version=3) when only the base template or versions {1,2} exist; a typo or case mismatch in the id; the .prompt file existed but failed frontmatter parsing during directory load (silently skipped); prompt_data key not matching the render id.","commonSituations":"Renaming a .prompt file without updating call sites; requesting a pinned version after regenerating prompts without version history; environments where the prompts directory path differed so nothing loaded (then Available prompts: []); assuming prompt_file loading keyed by filename stem when a custom id was passed.","solutions":["Inspect the error's 'Available prompts' list — it tells you exactly what registered and what the real id is","If the list is empty or missing the prompt, fix loading first (directory exists, frontmatter valid, id key matches)","Pass version=None to use the base template, or verify the specific version exists before requesting it","Pre-check with manager.get_prompt(prompt_id=..., version=...) is not None before render"],"exampleFix":"# before\ntext = manager.render('summarize', {'topic': 'litellm'})\n\n# after\nif manager.get_prompt(prompt_id='summarize') is None:\n    raise ValueError(\n        f\"prompt 'summarize' not loaded; loaded ids: {list(manager.prompts.keys())}\"\n    )\ntext = manager.render('summarize', {'topic': 'litellm'})","handlingStrategy":"validation","validationCode":"if manager.get_prompt(prompt_id=prompt_id, version=version) is None:\n    raise ValueError(\n        f\"prompt {prompt_id!r} (version={version}) not loaded; \"\n        f\"available: {sorted(manager.prompts.keys())}\"\n    )\ntext = manager.render(prompt_id, variables, version=version)","typeGuard":"def prompt_is_available(manager, prompt_id: str, version: int | None = None) -> bool:\n    return manager.get_prompt(prompt_id=prompt_id, version=version) is not None","tryCatchPattern":"try:\n    text = manager.render(prompt_id, variables)\nexcept KeyError as e:\n    raise ValueError(f'unknown prompt requested: {prompt_id}') from e","preventionTips":["After PromptManager construction, assert the expected ids are present: set(required) <= set(manager.prompts)","Remember directory loading silently skips broken files — check prompts.keys(), not the folder listing","Generate prompt ids from filenames (stem) in call sites to avoid drift"],"tags":["litellm","dotprompt","prompt","lookup","key-not-found"],"backgroundTag":"key-not-found","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}