BerriAI/litellm · error · ValueError
Prompt template ' ' not found
Error message
Prompt template '{prompt_id}' not found What it means
ValueError raised by BitBucketPromptManager.get_prompt_template when prompt_manager.get_template(prompt_id) returns None — the same root cause as render_template's 'Template not found' but on the get/render path used when compiling prompts for chat completion. The template was never loaded into the in-memory prompts dict (missing file, empty content, typo, wrong branch/directory).
Solutions
- Verify the id against the loaded set: prompt_manager.get_template(prompt_id) should be non-None before calling get_prompt_template
- Confirm <prompt_id>.prompt exists in the configured directory on the configured branch in BitBucket
- Restart/reinitialize the prompt manager after adding new prompt files — loading is not hot-reloaded
- Fix case mismatches and stray whitespace in the prompt_id
Example fix
// before
rendered, meta = manager.get_prompt_template("code-review", vars)
// after
tmpl = manager.prompt_manager.get_template("code-review")
if tmpl is None:
raise ValueError(f"'code-review' not loaded; have {manager.prompt_manager.list_templates()}")
rendered, meta = manager.get_prompt_template("code-review", vars) Defensive patterns
Strategy: type-guard
Validate before calling
if manager.prompt_manager.get_template(prompt_id) is None:
raise ValueError(f"prompt '{prompt_id}' not loaded; have {manager.prompt_manager.list_templates()}") Type guard
from litellm.integrations.bitbucket import BitBucketPromptManagementClient
def prompt_template_ready(client: BitBucketPromptManagementClient, prompt_id: str) -> bool:
return client.prompt_manager.get_template(prompt_id) is not None Try / catch
try:
rendered, meta = manager.get_prompt_template(prompt_id, variables)
except ValueError as e:
if "not found" in str(e):
manager.prompt_manager._load_prompt_from_bitbucket(prompt_id) # retry load once
rendered, meta = manager.get_prompt_template(prompt_id, variables)
else:
raise Prevention
- get_template() returns Optional — always None-check before get_prompt_template
- Validate prompt ids against the repo contents in CI
- Restart the prompt manager (or reload) after prompt files change; loading is not hot-reloaded
When it happens
Trigger: Calling get_prompt_template (directly or via compile_prompt_helper after a failed silent load) for an id that is not in self.prompts: file absent from the BitBucket directory on the configured branch, empty file content skipped at load, case/typo mismatch, or load happening before the file was committed.
Common situations: Prompt ids passed in request params ('prompt_id') that don't match repo filenames; prompts merged to a feature branch while the client watches 'main'; trailing whitespace in ids; teams expecting hot-reload when the manager only loads at init.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Template ' ' not found
- bitbucket_config is required for BitBucket prompt…
- BitBucket configuration not found. Please set…
- Error compiling prompt
- Failed to load prompt
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/2458037e9ea3f008.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/integrations/bitbucket/bitbucket_prompt_manager.py:251
def get_prompt_template(
self,
prompt_id: str,
prompt_variables: dict[str, Any] | None = None,
) -> tuple[str, dict[str, Any]]:
"""
Get a prompt template and render it with variables.
Args:
prompt_id: The ID of the prompt template
prompt_variables: Variables to substitute in the template
Returns:
Tuple of (rendered_prompt, metadata)
"""
template: Final = self.prompt_manager.get_template(prompt_id)
if not template:
raise ValueError(f"Prompt template '{prompt_id}' not found")
# Render the template
rendered_prompt: Final = self.prompt_manager.render_template(prompt_id, prompt_variables or {})
# Extract metadata
metadata: Final = {
"model": template.model,
"temperature": template.temperature,
"max_tokens": template.max_tokens,
**template.optional_params,
}
return rendered_prompt, metadata
def pre_call_hook(
self,
user_id: str | None,
messages: list[AllMessageValues],View on GitHub (pinned to 77b7c6c40c)