OpenBMB/ChatDev · error · HTTPException

invalid_yaml

invalid_yaml

Error message

invalid_yaml

What it means

The /schema/validate endpoint could not parse the submitted YAML document; yaml.safe_load raised a YAMLError. The raw parser message is included in the detail.error field. This happens before any schema validation, so nothing about the document's structure was checked yet.

Source

Thrown at server/config_schema_router.py:50

        return build_schema_response(breadcrumbs)
    except SchemaResolutionError:
        return None


@router.post("/schema")
def get_schema(request: SchemaRequest) -> Dict[str, Any]:
    try:
        return build_schema_response(request.breadcrumbs)
    except SchemaResolutionError as exc:
        raise HTTPException(status_code=422, detail={"message": str(exc)}) from exc


@router.post("/schema/validate")
def validate_document(request: SchemaValidateRequest) -> Dict[str, Any]:
    try:
        parsed = yaml.safe_load(request.document)
    except yaml.YAMLError as exc:
        raise HTTPException(status_code=400, detail={"message": "invalid_yaml", "error": str(exc)}) from exc

    if not isinstance(parsed, Mapping):
        raise HTTPException(status_code=422, detail={"message": "document_root_not_mapping"})

    try:
        load_design_from_mapping(parsed)
    except ConfigError as exc:
        return {
            "valid": False,
            "error": str(exc),
            "path": exc.path,
            "schema": _resolve_schema(request.breadcrumbs),
        }

    return {
        "valid": True,
        "schema": _resolve_schema(request.breadcrumbs),
    }

View on GitHub (pinned to 4fb2db0ea9)

Solutions

  1. Fix the YAML syntax reported in detail.error (line/column is included)
  2. Replace tabs with spaces in indentation
  3. Validate locally with python -c "import yaml,sys;yaml.safe_load(open(sys.argv[1]))" file.yaml before submitting
  4. Use a YAML linting plugin in your editor

Example fix

// before
document: "tasks:\n\t- name: run"  // tab indentation
// after
document: "tasks:\n  - name: run"
Defensive patterns

Strategy: validation

Validate before calling

import yaml
def safe_yaml(doc: str):
    try:
        yaml.safe_load(doc)
        return True
    except yaml.YAMLError:
        return False

Try / catch

# server response is HTTP 400 with detail.message == 'invalid_yaml'
if resp.status_code == 400 and resp.json()['detail']['message'] == 'invalid_yaml':
    print(resp.json()['detail']['error'])  # parser message with line/col

Prevention

When it happens

Trigger: POST /schema/validate with a document containing syntax errors: bad indentation, unclosed quotes or brackets, tabs used for indentation, or duplicate keys under strict parsing.

Common situations: User-edited YAML files, LLM-generated YAML with inconsistent indentation, tabs pasted from editors, copy-paste artifacts that break block scalars.

Related errors


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