OpenBB-finance/OpenBB · error · ValueError
Prompt content cannot be empty
Error message
Prompt content cannot be empty
What it means
Pydantic validation error on PromptConfigModel.content: the prompt template is empty or only whitespace. Prompt content is the rendered message body sent to the model, so an empty template is meaningless and is rejected. It fires when a config entry has content: "", content: null coerced oddly, or a whitespace-only string.
Source
Thrown at openbb_platform/extensions/mcp_server/openbb_mcp_server/models/mcp_config.py:106
default=None, description="Name of the prompt (auto-generated if not provided)"
)
description: str | None = Field(
default=None, description="Description of the prompt"
)
content: str = Field(description="Template content with {variable} placeholders")
arguments: list[ArgumentDefinitionModel] = Field(
default_factory=list, description="Argument definitions for the prompt"
)
tags: list[str] = Field(
default_factory=list, description="Tags for categorizing the prompt"
)
@field_validator("content")
@classmethod
def validate_content(cls, v: str) -> str:
"""Validate content is not empty and contains valid template syntax."""
if not v.strip():
raise ValueError("Prompt content cannot be empty")
# Check for unmatched braces
open_braces = v.count("{")
close_braces = v.count("}")
if open_braces != close_braces:
raise ValueError(
f"Unmatched braces in prompt content: {open_braces} opening, {close_braces} closing"
)
return v
@field_validator("name")
@classmethod
def validate_name(cls, v: str | None) -> str | None:
"""Validate prompt name if provided."""
if v is not None:
if not v.strip():
raise ValueError("Prompt name cannot be empty string")View on GitHub (pinned to 3e071fcc2c)
Solutions
- Provide non-empty prompt text under the content key.
- For YAML block scalars, indent the template body under content: |.
- If generating configs, skip or fail loudly when the rendered template is blank.
Example fix
# before (content is empty)
prompts:
- name: greet
content:
# after
prompts:
- name: greet
content: |
Summarize the following data: {data} Defensive patterns
Strategy: validation
Validate before calling
def validate_prompts(prompts: list[dict]) -> None:
for p in prompts:
if not str(p.get("content", "")).strip():
raise ValueError(f"prompt {p.get('name', '<unnamed>')} has empty content") Type guard
def has_nonempty_content(prompt_cfg: dict) -> bool:
return bool(str(prompt_cfg.get("content", "")).strip()) Prevention
- In YAML, indent template bodies under content: | block scalars.
- Fail config generation loudly when a rendered template is blank.
- Load configs through PromptConfigModel in CI to catch this early.
When it happens
Trigger: Loading an MCP prompt config whose content key is blank or missing text; YAML multiline scalars that collapse to empty (e.g. content: | with nothing indented under it); generators emitting prompts with unfilled templates.
Common situations: YAML indentation errors emptying a block scalar; templating pipelines producing '' for all entries; configs split across files with content defined in the wrong node.
Related errors
- Argument name cannot be empty
- Type '{v}' not recognized. Valid types: {', '.join(sorted(va
- Unmatched braces in prompt content: {open_braces} opening, {
- Prompt name cannot be empty string
- Prompt name '{v}' should be a valid identifier
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/ee0fd4049c6b50a2.
Report an issue: GitHub.