{"record":{"id":"a6f76b4baead8dd3","repo":"FoundationAgents/MetaGPT","slug":"error-parsing-yaml-file-file-name-str-e","errorCode":null,"errorMessage":"Error parsing YAML file '{FILE_NAME}': {str(e)}","messagePattern":"Error parsing YAML file '(.+?)': (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/ext/spo/utils/load.py","lineNumber":26,"sourceCode":"\n\ndef set_file_name(name: str):\n    global FILE_NAME\n    FILE_NAME = name\n\n\ndef load_meta_data(k: int = SAMPLE_K):\n    # load yaml file\n    config_path = Path(__file__).parent.parent / \"settings\" / FILE_NAME\n\n    if not config_path.exists():\n        raise FileNotFoundError(f\"Configuration file '{FILE_NAME}' not found in settings directory\")\n\n    try:\n        with config_path.open(\"r\", encoding=\"utf-8\") as file:\n            data = yaml.safe_load(file)\n    except yaml.YAMLError as e:\n        raise ValueError(f\"Error parsing YAML file '{FILE_NAME}': {str(e)}\")\n    except Exception as e:\n        raise Exception(f\"Error reading file '{FILE_NAME}': {str(e)}\")\n\n    qa = []\n\n    for item in data[\"qa\"]:\n        question = item[\"question\"]\n        answer = item[\"answer\"]\n        qa.append({\"question\": question, \"answer\": answer})\n\n    prompt = data[\"prompt\"]\n    requirements = data[\"requirements\"]\n    count = data[\"count\"]\n\n    if isinstance(count, int):\n        count = f\", within {count} words\"\n    else:\n        count = \"\"","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/ext/spo/utils/load.py#L8-L44","documentation":"Raised when yaml.safe_load fails while parsing the SPO settings file selected by FILE_NAME. The underlying YAMLError details (line/column, scanner or parser error) are included in the message, pinpointing the syntax problem in the yaml.","triggerScenarios":"Tabs used for indentation, unquoted strings containing special yaml characters (:, {, [, *), duplicated keys with conflicting constructs, or truncated file content in metagpt/ext/spo/settings/<FILE_NAME>.","commonSituations":"Hand-editing the qa/prompt/requirements yaml and breaking syntax; copy-pasting prompts containing colons without quotes; merge conflicts left unresolved in the settings file.","solutions":["Read the line/column in the message and fix the yaml syntax there.","Run python -c \"import yaml; yaml.safe_load(open('metagpt/ext/spo/settings/<FILE>'))\" to iterate quickly outside MetaGPT.","Quote prompt strings that contain ': ' or yaml special characters; use block scalars (| or >) for long prompts.","Resolve any leftover merge-conflict markers in the file."],"exampleFix":"# before (invalid: unquoted colon)\nprompt: Analyze this: step by step\n\n# after\nprompt: |\n  Analyze this: step by step","handlingStrategy":"validation","validationCode":"import yaml\n\ndef validate_spo_settings(path: str):\n    with open(path, encoding=\"utf-8\") as f:\n        data = yaml.safe_load(f)\n    assert {\"qa\", \"prompt\", \"requirements\", \"count\"} <= set(data), \"missing keys in settings yaml\"\n    return data","typeGuard":null,"tryCatchPattern":"try:\n    data = load_meta_data()\nexcept ValueError as e:\n    if \"Error parsing YAML\" in str(e):\n        # re-run yaml.safe_load yourself to get position; guide user to fix line\n        raise\n    raise","preventionTips":["Lint settings yaml in CI.","Use block scalars for prompts containing colons."],"tags":["yaml","configuration","spo","parse-error"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}