{"record":{"id":"1bf680fbec2a2b27","repo":"BerriAI/litellm","slug":"template-template-id-not-found-1bf680","errorCode":null,"errorMessage":"Template '{template_id}' not found","messagePattern":"Template '(.+?)' not found","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/bitbucket/bitbucket_prompt_manager.py","lineNumber":168,"sourceCode":"                key, value = line.split(\":\", 1)\n                key = key.strip()\n                value = value.strip()\n\n                # Try to parse value as appropriate type\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                    result[key] = float(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        \"\"\"Render a template with the given variables.\"\"\"\n        if template_id not in self.prompts:\n            raise ValueError(f\"Template '{template_id}' not found\")\n\n        template: Final = self.prompts[template_id]\n        jinja_template: Final = self.jinja_env.from_string(template.content)\n\n        return jinja_template.render(**(variables or {}))\n\n    def get_template(self, template_id: str) -> BitBucketPromptTemplate | None:\n        \"\"\"Get a template by ID.\"\"\"\n        return self.prompts.get(template_id)\n\n    def list_templates(self) -> list[str]:\n        \"\"\"List all available template IDs.\"\"\"\n        return list(self.prompts.keys())\n\n\nclass BitBucketPromptManager(CustomPromptManagement):\n    \"\"\"\n    BitBucket prompt manager that integrates with LiteLLM's prompt management system.","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/bitbucket/bitbucket_prompt_manager.py#L150-L186","documentation":"ValueError raised by BitBucketPromptManager.render_template when the requested template_id has not been loaded into the in-memory self.prompts dict. Loading happens at manager initialization and via _load_prompt_from_bitbucket; if the id was never loaded (or loading failed silently in a code path that swallows errors), rendering refuses to guess and raises.","triggerScenarios":"Calling render_template('summary') before load_prompts ran, using a prompt_id with different casing/whitespace than the file name (prompt ids come from file names), or after a failed load left self.prompts empty.","commonSituations":"Prompt file added to the repo after the proxy started, so the manager never saw it; trailing newline in an id read from config; tests calling render_template on a fresh manager instance.","solutions":["Check prompt id membership first: if template_id not in manager.prompts: manager._load_prompt_from_bitbucket(template_id)","Verify the id matches the .prompt file name exactly (case-sensitive, no extension)","Call list_templates() to see what ids are actually loaded","Restart or re-run the initial directory scan after adding new prompt files to the repository"],"exampleFix":"# before\nrendered = manager.render_template(\"summary\", {\"tone\": \"formal\"})\n\n# after (lazy-load on miss)\nif \"summary\" not in manager.prompts:\n    manager._load_prompt_from_bitbucket(\"summary\")\nrendered = manager.render_template(\"summary\", {\"tone\": \"formal\"})","handlingStrategy":"validation","validationCode":"def ensure_template(manager, template_id: str) -> bool:\n    if template_id not in manager.prompts:\n        try:\n            manager._load_prompt_from_bitbucket(template_id)\n        except Exception:\n            return False\n    return template_id in manager.prompts","typeGuard":"def is_loaded_template(manager, template_id: str) -> bool:\n    \"\"\"True if template_id is loaded and renderable.\"\"\"\n    return isinstance(template_id, str) and template_id in manager.prompts","tryCatchPattern":"try:\n    rendered = manager.render_template(tid, variables)\nexcept ValueError as e:\n    if \"not found\" in str(e):\n        manager._load_prompt_from_bitbucket(tid)\n        rendered = manager.render_template(tid, variables)\n    else:\n        raise","preventionTips":["Lazy-load on miss before rendering","Use list_templates() in smoke tests to assert expected ids are present","Keep prompt ids identical to file names, case-sensitively"],"tags":["bitbucket","prompts","rendering","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}