OpenBMB/ChatDev · error · ConfigError

content cannot be empty

Error message

content cannot be empty

What it means

LiteralNodeConfig.from_dict requires 'content' to be a truthy string. require_str already enforces string type; this check rejects an empty string, so a literal message node must carry actual text.

Source

Thrown at entity/configs/node/literal.py:30

    require_mapping,
    require_str,
)
from entity.messages import MessageRole


@dataclass
class LiteralNodeConfig(BaseConfig):
    """Config describing the literal payload emitted by the node."""

    content: str = ""
    role: MessageRole = MessageRole.USER

    @classmethod
    def from_dict(cls, data: Mapping[str, Any], *, path: str) -> "LiteralNodeConfig":
        mapping = require_mapping(data, path)
        content = require_str(mapping, "content", path)
        if not content:
            raise ConfigError("content cannot be empty", f"{path}.content")

        role_value = optional_str(mapping, "role", path)
        role = MessageRole.USER
        if role_value:
            normalized = role_value.strip().lower()
            if normalized not in (MessageRole.USER.value, MessageRole.ASSISTANT.value):
                raise ConfigError("role must be 'user' or 'assistant'", f"{path}.role")
            role = MessageRole(normalized)

        return cls(content=content, role=role, path=path)

    def validate(self) -> None:
        if not self.content:
            raise ConfigError("content cannot be empty", f"{self.path}.content")
        if self.role not in (MessageRole.USER, MessageRole.ASSISTANT):
            raise ConfigError("role must be 'user' or 'assistant'", f"{self.path}.role")

    FIELD_SPECS = {

View on GitHub (pinned to 4fb2db0ea9)

Solutions

  1. Provide non-empty text for 'content'
  2. If the value comes from a variable, add a fallback: content or 'placeholder'
  3. Validate user-authored message content before serializing the node config

Example fix

# before
LiteralNodeConfig.from_dict({"content": ""}, path="n1")
# after
LiteralNodeConfig.from_dict({"content": "Hello"}, path="n1")
Defensive patterns

Strategy: validation

Validate before calling

content = data.get('content')
if not isinstance(content, str) or not content:
    raise ValueError('literal content missing')  # or default: data['content'] = '...'

Type guard

def has_literal_content(data: dict) -> bool:
    c = data.get('content')
    return isinstance(c, str) and bool(c)

Try / catch

try:
    LiteralNodeConfig.from_dict(data, path='n1')
except ConfigError as e:
    if e.path.endswith('content'):
        data['content'] = '(empty message)'
        LiteralNodeConfig.from_dict(data, path='n1')
    else:
        raise

Prevention

When it happens

Trigger: Building a literal node from a dict where 'content' is '' (or a string that is empty after being passed through). Missing/non-string 'content' fails earlier in require_str with a different message.

Common situations: UI-authored message nodes left blank before saving; templates inserting an empty variable into content; trimming user input down to ''.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27). Data as JSON: /api/errors/6fd5065c4a7524cf. Report an issue: GitHub.