BerriAI/litellm · error · ValueError
Template '{template_id}' not found
Error message
Template '{template_id}' not found What it means
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.
Source
Thrown at litellm/integrations/bitbucket/bitbucket_prompt_manager.py:168
key, value = line.split(":", 1)
key = key.strip()
value = value.strip()
# Try to parse value as appropriate type
if value.lower() in ["true", "false"]:
result[key] = value.lower() == "true"
elif value.isdigit():
result[key] = int(value)
elif value.replace(".", "").isdigit():
result[key] = float(value)
else:
result[key] = value.strip("\"'")
return result
def render_template(self, template_id: str, variables: dict[str, Any] | None = None) -> str:
"""Render a template with the given variables."""
if template_id not in self.prompts:
raise ValueError(f"Template '{template_id}' not found")
template: Final = self.prompts[template_id]
jinja_template: Final = self.jinja_env.from_string(template.content)
return jinja_template.render(**(variables or {}))
def get_template(self, template_id: str) -> BitBucketPromptTemplate | None:
"""Get a template by ID."""
return self.prompts.get(template_id)
def list_templates(self) -> list[str]:
"""List all available template IDs."""
return list(self.prompts.keys())
class BitBucketPromptManager(CustomPromptManagement):
"""
BitBucket prompt manager that integrates with LiteLLM's prompt management system.View on GitHub (pinned to 6c2dcb801b)
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
Example fix
# before
rendered = manager.render_template("summary", {"tone": "formal"})
# after (lazy-load on miss)
if "summary" not in manager.prompts:
manager._load_prompt_from_bitbucket("summary")
rendered = manager.render_template("summary", {"tone": "formal"}) Defensive patterns
Strategy: validation
Validate before calling
def ensure_template(manager, template_id: str) -> bool:
if template_id not in manager.prompts:
try:
manager._load_prompt_from_bitbucket(template_id)
except Exception:
return False
return template_id in manager.prompts Type guard
def is_loaded_template(manager, template_id: str) -> bool:
"""True if template_id is loaded and renderable."""
return isinstance(template_id, str) and template_id in manager.prompts Try / catch
try:
rendered = manager.render_template(tid, variables)
except ValueError as e:
if "not found" in str(e):
manager._load_prompt_from_bitbucket(tid)
rendered = manager.render_template(tid, variables)
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Prompt template '{prompt_id}' not found
- prompt_id is required for BitBucket prompt manager
- Invalid file path {file_path!r}: path traversal detected
- workspace, repository, and access_token are required
- Failed to load prompt '{prompt_id}' from BitBucket: {e}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/1bf680fbec2a2b27.
Report an issue: GitHub.