{"record":{"id":"a22ba1a4950b14d4","repo":"BerriAI/litellm","slug":"template-template-id-not-found-a22ba1","errorCode":null,"errorMessage":"Template '{template_id}' not found","messagePattern":"Template '(.+?)' not found","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/gitlab/gitlab_prompt_manager.py","lineNumber":211,"sourceCode":"                key, value = line.split(\":\", 1)\n                key = key.strip()\n                value = value.strip()\n                if value.lower() in [\"true\", \"false\"]:\n                    result[key] = value.lower() == \"true\"\n                elif value.isdigit():\n                    result[key] = int(value)\n                elif value.replace(\".\", \"\").isdigit():\n                    try:\n                        result[key] = float(value)\n                    except Exception:\n                        result[key] = value\n                else:\n                    result[key] = value.strip(\"\\\"'\")\n        return result\n\n    def render_template(self, template_id: str, variables: dict[str, Any] | None = None) -> str:\n        if template_id not in self.prompts:\n            raise ValueError(f\"Template '{template_id}' not found\")\n        template: Final = self.prompts[template_id]\n        jinja_template: Final = self.jinja_env.from_string(template.content)\n        return jinja_template.render(**(variables or {}))\n\n    def get_template(self, template_id: str) -> GitLabPromptTemplate | None:\n        return self.prompts.get(template_id)\n\n    def list_templates(self, *, recursive: bool = True) -> list[str]:\n        \"\"\"\n        List available prompt IDs under prompts_path (no extension).\n        Compatible with both list_files signatures:\n        - list_files(directory_path=..., file_extension=..., recursive=...)\n        - list_files(path=..., ref=None, recursive=...)\n        \"\"\"\n        # First try the \"new\" signature (directory_path/file_extension)\n        try:\n            files = self.gitlab_client.list_files(\n                directory_path=self.prompts_path,","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/gitlab/gitlab_prompt_manager.py#L193-L229","documentation":"ValueError raised by GitLabPromptManager.render_template when the requested template_id is not present in the in-memory self.prompts dict. The manager only renders templates that were previously loaded from GitLab; it does not lazy-load inside render_template.","triggerScenarios":"Calling render_template('my_prompt', vars) before _load_prompt_from_gitlab('my_prompt') or load_all_prompts() has populated it; using a template id with a different spelling/case than the file-derived id; after a failed silent load.","commonSituations":"Skipping the eager load step in initialization; ids derived from filenames (extension stripped) so 'greeting.prompt' must be rendered as 'greeting'; process restart losing in-memory cache while code assumes persistence.","solutions":["Call load_all_prompts() first, or _load_prompt_from_gitlab(template_id), before render_template","Verify the id via list_templates() — ids are file paths without the .prompt extension","Check exact spelling/case of the id","Prefer the higher-level get_prompt_template() which lazy-loads on miss"],"exampleFix":"# before\nrendered = manager.render_template('greeting', {'name': 'A'})\n\n# after\nif 'greeting' not in manager.prompts:\n    manager._load_prompt_from_gitlab('greeting')\nrendered = manager.render_template('greeting', {'name': 'A'})","handlingStrategy":"validation","validationCode":"if template_id not in manager.prompts:\n    manager._load_prompt_from_gitlab(template_id)\nassert template_id in manager.prompts, f\"{template_id} unavailable\"","typeGuard":"def is_loaded_template(manager, template_id: str) -> bool:\n    \"\"\"Narrow: True only if the id is loaded and renderable.\"\"\"\n    return isinstance(template_id, str) and template_id in manager.prompts","tryCatchPattern":"try:\n    out = manager.render_template(tid, vars)\nexcept ValueError as e:\n    if \"not found\" in str(e):\n        manager._load_prompt_from_gitlab(tid)\n        out = manager.render_template(tid, vars)\n    else:\n        raise","preventionTips":["Call load_all_prompts() once at startup","Guard renders with a membership check on manager.prompts","Derive ids from list_templates(), not hardcoded guesses"],"tags":["gitlab","prompt-management","litellm","state"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}