{"record":{"id":"2d528939e4930108","repo":"OpenBMB/ChatDev","slug":"invalid-yaml-syntax-exc","errorCode":null,"errorMessage":"Invalid YAML syntax: {exc}","messagePattern":"Invalid YAML syntax: (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"server/services/workflow_storage.py","lineNumber":79,"sourceCode":"\n    return Path(value).name\n\n\ndef validate_workflow_content(filename: str, content: str) -> Tuple[str, Any]:\n    safe_filename = validate_workflow_filename(filename, require_yaml_extension=True)\n\n    try:\n        yaml_content = yaml.safe_load(content)\n        if yaml_content is None:\n            raise ValidationError(\"YAML content is empty\", field=\"content\")\n\n        errors = check_config(yaml_content)\n        if errors:\n            raise ValidationError(f\"YAML validation errors:\\n{errors}\", field=\"content\")\n    except yaml.YAMLError as exc:\n        logger = get_server_logger()\n        logger.warning(\"Invalid YAML content in upload\", details={\"error\": str(exc)})\n        raise ValidationError(f\"Invalid YAML syntax: {exc}\", field=\"content\")\n\n    return safe_filename, yaml_content\n\n\ndef persist_workflow(\n    safe_filename: str,\n    content: str,\n    yaml_content: Any,\n    *,\n    action: str,\n    directory: Path,\n) -> None:\n    save_path = directory / safe_filename\n    logger = get_server_logger()\n\n    try:\n        save_path.write_text(content, encoding=\"utf-8\")\n    except Exception as exc:","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/server/services/workflow_storage.py#L61-L97","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the YAML syntax at the location given in the exception message (line/column from yaml.YAMLError)","Validate locally with yaml.safe_load() or a YAML linter before uploading","Ensure no tab indentation — YAML requires spaces","If content is built programmatically, serialize with yaml.safe_dump instead of string concatenation"],"exampleFix":"# before\ncontent = \"steps:\\n\\t- name: run\\\"  # tab + stray quote\n# after\ncontent = \"steps:\\n  - name: run\"\nimport yaml; yaml.safe_load(content)  # verify before upload","handlingStrategy":"validation","validationCode":"import yaml\ntry:\n    yaml.safe_load(content)\nexcept yaml.YAMLError as e:\n    print('invalid YAML:', e)","typeGuard":null,"tryCatchPattern":"try:\n    validate_workflow_content(content)\nexcept ValidationError as e:\n    if 'YAML syntax' in str(e):\n        show_editor_error(e)  # surface line/col to user","preventionTips":["Run yaml.safe_load locally before upload","Use a YAML-aware editor with linting","Never indent YAML with tabs","Generate YAML with safe_dump rather than string templates"],"tags":["yaml","workflow","validation","upload"],"backgroundTag":"yaml-parse-error","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}