{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/bitbucket/bitbucket_prompt_manager.py#L150-L186","documentation":"ValueError raised by BitBucketPromptManager.render_template when the requested template_id is not a key in the in-memory self.prompts dict. That dict is populated by listing the configured directory at init and downloading each .prompt file; because a 404 or empty file content is silently skipped during load, a file that 'should exist' can still be absent from the cache at render time.","triggerScenarios":"Calling render_template with a typo'd or case-mismatched id; the .prompt file not existing in the configured BitBucket directory (load-time 404 was swallowed); the file existing but being empty ('' is falsy so it is never cached); rendering before the file was pushed to the repo; wrong prompts directory configured so nothing was loaded.","commonSituations":"Case-sensitivity mistakes ('Summarize' vs 'summarize'); prompts pushed to a different branch than the configured 'branch' (default 'main'); CI deploying the proxy before the prompts repo is updated; directory config pointing at a folder that has no .prompt files.","solutions":["List what actually loaded: print(manager.list_templates()) and compare against the id you passed","Confirm the file exists on the configured branch: check <workspace>/<repo>/src/<branch>/<dir>/<id>.prompt in BitBucket UI","Fix typos and case — ids are exact-match keys","If the file is empty, add content; empty files are silently skipped at load time"],"exampleFix":"// before\nout = manager.render_template(\"summarize-v2\", {\"text\": t})\n\n// after\nif \"summarize-v2\" not in manager.list_templates():\n    raise KeyError(f\"prompt not loaded; available: {manager.list_templates()}\")\nout = manager.render_template(\"summarize-v2\", {\"text\": t})","handlingStrategy":"validation","validationCode":"available = set(manager.list_templates())\nif template_id not in available:\n    raise KeyError(f\"template '{template_id}' not loaded; available: {sorted(available)}\")\nout = manager.render_template(template_id, variables)","typeGuard":"def can_render(manager, template_id: str) -> bool:\n    return template_id in manager.prompts","tryCatchPattern":"try:\n    out = manager.render_template(template_id, variables)\nexcept ValueError as e:\n    if \"not found\" in str(e):\n        ...  # reload templates / fix id\n    raise","preventionTips":["Log list_templates() at startup and compare against configured prompt ids","Treat empty .prompt files as CI failures — they are silently skipped at load and break render later","Deploy prompts to the configured branch (default 'main') before deploying the proxy","Use exact case-matching ids everywhere"],"tags":["bitbucket","prompt-management","template-render","resource-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}