BerriAI/litellm · error · ValueError
Invalid type for field '{field_name}': expected {getattr(exp
Error message
Invalid type for field '{field_name}': expected {getattr(expected_type, '__name__', str(expected_type))}, got {type(value).__name__} What it means
Error "Invalid type for field '{field_name}': expected {getattr(expected_type, '__name__', str(expected_type))}, got {type(value).__name__}" thrown in BerriAI/litellm.
Source
Thrown at litellm/integrations/dotprompt/prompt_manager.py:234
self._validate_input(variables, template.input_schema)
try:
# Create Jinja2 template and render
jinja_template: Final = self.jinja_env.from_string(template.content)
rendered: Final = jinja_template.render(**variables)
return rendered
except Exception as e:
raise ValueError(f"Error rendering template '{prompt_id}': {e}")
def _validate_input(self, variables: dict[str, Any], schema: dict[str, Any]) -> None:
"""Basic validation of input variables against schema."""
for field_name, field_type in schema.items():
if field_name in variables:
value = variables[field_name]
expected_type = self._get_python_type(field_type)
if not isinstance(value, expected_type):
raise ValueError(
f"Invalid type for field '{field_name}': "
f"expected {getattr(expected_type, '__name__', str(expected_type))}, got {type(value).__name__}"
)
def _get_python_type(self, schema_type: str) -> type | tuple:
"""Convert schema type string to Python type."""
type_mapping: Final[dict[str, type | tuple]] = {
"string": str,
"str": str,
"number": (int, float),
"integer": int,
"int": int,
"float": float,
"boolean": bool,
"bool": bool,
"array": list,
"list": list,
"object": dict,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass a value of the expected type for the frontmatter field.
When it happens
Trigger: Thrown at litellm/integrations/dotprompt/prompt_manager.py:234 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/41e9e8ee36136306.
Report an issue: GitHub.