BerriAI/litellm · error · ValueError
Prompt template '{prompt_id}' not found
Error message
Prompt template '{prompt_id}' not found What it means
ValueError raised by CustomGitLabPromptManagement.get_prompt_template when, after attempting a lazy load via _load_prompt_from_gitlab, the template still isn't in the manager. The silent-None path: get_file_content returns None on 404, so the template is never cached, and this error surfaces the miss.
Source
Thrown at litellm/integrations/gitlab/gitlab_prompt_manager.py:325
prompt_id=self.prompt_id,
ref=self._ref_override,
gitlab_client=self._injected_gitlab_client,
)
return self._prompt_manager
def get_prompt_template(
self,
prompt_id: str,
prompt_variables: dict[str, Any] | None = None,
*,
ref: str | None = None,
) -> tuple[str, dict[str, Any]]:
if prompt_id not in self.prompt_manager.prompts:
self.prompt_manager._load_prompt_from_gitlab(prompt_id, ref=ref)
template: Final = self.prompt_manager.get_template(prompt_id)
if not template:
raise ValueError(f"Prompt template '{prompt_id}' not found")
rendered_prompt: Final = self.prompt_manager.render_template(prompt_id, prompt_variables or {})
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],
function_call: dict[str, Any] | str | None = None,
litellm_params: dict[str, Any] | None = None,
prompt_id: str | None = None,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Confirm the file exists: browse the repo at the exact path _id_to_repo_path produces for your id
- Check prompts_path setting matches where .prompt files live
- Pass the id exactly as returned by list_templates()
- If using ref, ensure the branch/tag actually contains the file
Defensive patterns
Strategy: validation
Validate before calling
available = prompt_manager.list_templates()
if prompt_id not in available:
raise LookupError(f"prompt '{prompt_id}' missing; available: {available}") Try / catch
try:
rendered, meta = handler.get_prompt_template(pid, variables, ref=ref)
except ValueError as e:
if "not found" in str(e):
# 404 path: file absent at ref — handle gracefully
raise LookupError(f"prompt file missing in GitLab at ref={ref}") from e
raise Prevention
- Cross-check prompt ids against list_templates() output
- Verify prompts_path config matches repo layout
- Test the ref actually contains the file before pinning it
When it happens
Trigger: Calling get_prompt_template with a prompt_id whose .prompt file does not exist in the repo at the resolved path (404 -> content None -> no template), or when the prompts_path prefix misroutes the id to a nonexistent location.
Common situations: Prompt file deleted or renamed in GitLab; prompts_path config pointing at the wrong directory; id passed with the '.prompt' extension or a leading slash causing path mismatch; ref (branch) that lacks the file.
Related errors
- Failed to load prompt '{encode_prompt_id(prompt_id)}' from G
- Template '{template_id}' not found
- prompt_id is required for GitLab prompt manager
- Error compiling prompt '{prompt_id}': {e}
- Gitlab configuration not found. Please set litellm.global_gi
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/c68fe430bcf187d4.
Report an issue: GitHub.