OpenBMB/ChatDev · error · ValidationError

Invalid YAML syntax: {exc}

Error message

Invalid YAML syntax: {exc}

What it means

Raised by validate_workflow_content when the uploaded workflow content cannot be parsed as YAML (yaml.YAMLError from the parser). The content is rejected before persistence, so no file is written. A separate ValidationError with aggregated check_config results is raised when syntax parses but schema validation fails.

Source

Thrown at server/services/workflow_storage.py:79

    return Path(value).name


def validate_workflow_content(filename: str, content: str) -> Tuple[str, Any]:
    safe_filename = validate_workflow_filename(filename, require_yaml_extension=True)

    try:
        yaml_content = yaml.safe_load(content)
        if yaml_content is None:
            raise ValidationError("YAML content is empty", field="content")

        errors = check_config(yaml_content)
        if errors:
            raise ValidationError(f"YAML validation errors:\n{errors}", field="content")
    except yaml.YAMLError as exc:
        logger = get_server_logger()
        logger.warning("Invalid YAML content in upload", details={"error": str(exc)})
        raise ValidationError(f"Invalid YAML syntax: {exc}", field="content")

    return safe_filename, yaml_content


def persist_workflow(
    safe_filename: str,
    content: str,
    yaml_content: Any,
    *,
    action: str,
    directory: Path,
) -> None:
    save_path = directory / safe_filename
    logger = get_server_logger()

    try:
        save_path.write_text(content, encoding="utf-8")
    except Exception as exc:

View on GitHub (pinned to 4fb2db0ea9)

Solutions

  1. Fix the YAML syntax at the location given in the exception message (line/column from yaml.YAMLError)
  2. Validate locally with yaml.safe_load() or a YAML linter before uploading
  3. Ensure no tab indentation — YAML requires spaces
  4. If content is built programmatically, serialize with yaml.safe_dump instead of string concatenation

Example fix

# before
content = "steps:\n\t- name: run\"  # tab + stray quote
# after
content = "steps:\n  - name: run"
import yaml; yaml.safe_load(content)  # verify before upload
Defensive patterns

Strategy: validation

Validate before calling

import yaml
try:
    yaml.safe_load(content)
except yaml.YAMLError as e:
    print('invalid YAML:', e)

Try / catch

try:
    validate_workflow_content(content)
except ValidationError as e:
    if 'YAML syntax' in str(e):
        show_editor_error(e)  # surface line/col to user

Prevention

When it happens

Trigger: Uploading a workflow whose content has bad YAML: tabs for indentation, unclosed quotes/brackets, duplicate keys, or a completely empty/garbage body sent as the content field.

Common situations: Copy-pasting YAML from docs or chat introduces tab characters; templating leaves placeholder tokens like ${VAR} that break parsing; client sends JSON-stringified content double-escaped, producing invalid YAML.

Related errors


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