BerriAI/litellm · error · ValueError
Invalid YAML frontmatter: {e}
Error message
Invalid YAML frontmatter: {e} What it means
Error "Invalid YAML frontmatter: {e}" thrown in BerriAI/litellm.
Source
Thrown at litellm/integrations/dotprompt/prompt_manager.py:175
content=template_content.strip(),
metadata=frontmatter,
template_id=prompt_id,
)
def _parse_frontmatter(self, content: str) -> tuple[dict[str, Any], str]:
"""Parse YAML frontmatter from prompt content."""
# Match YAML frontmatter between --- delimiters
frontmatter_pattern: Final = r"^---\s*\n(.*?)\n---\s*\n(.*)$"
match: Final = re.match(frontmatter_pattern, content, re.DOTALL)
if match:
frontmatter_yaml: Final = match.group(1)
template_content = match.group(2)
try:
frontmatter = yaml.safe_load(frontmatter_yaml) or {}
except yaml.YAMLError as e:
raise ValueError(f"Invalid YAML frontmatter: {e}")
else:
# No frontmatter found, treat entire content as template
frontmatter = {}
template_content = content
return frontmatter, template_content
def render(
self,
prompt_id: str,
prompt_variables: dict[str, Any] | None = None,
version: int | None = None,
) -> str:
"""
Render a prompt template with the given variables.
Args:
prompt_id: The ID of the prompt template to renderView on GitHub (pinned to 6c2dcb801b)
Solutions
- Fix the YAML frontmatter in the .prompt file.
When it happens
Trigger: Thrown at litellm/integrations/dotprompt/prompt_manager.py:175 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/4d5c6b490dd9f728.
Report an issue: GitHub.