{"record":{"id":"84661101cb9002a3","repo":"FoundationAgents/MetaGPT","slug":"configuration-file-file-name-not-found-in-sett","errorCode":null,"errorMessage":"Configuration file '{FILE_NAME}' not found in settings directory","messagePattern":"Configuration file '(.+?)' not found in settings directory","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"metagpt/ext/spo/utils/load.py","lineNumber":20,"sourceCode":"from pathlib import Path\n\nimport yaml\n\nFILE_NAME = \"\"\nSAMPLE_K = 3\n\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\"]","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/ext/spo/utils/load.py#L2-L38","documentation":"load_meta_data builds a path metagpt/ext/spo/settings/<FILE_NAME> and raises FileNotFoundError when it does not exist. FILE_NAME is a module global that is empty until set_file_name(name) is called, so forgetting to set it — or setting a name with no matching yaml in the settings directory — both produce this error.","triggerScenarios":"Calling load_meta_data() before set_file_name('my_settings.yaml'); passing a file name that differs from the actual file in metagpt/ext/spo/settings/ (wrong extension, typo, leading path component).","commonSituations":"New SPO experiments where the developer created a custom settings yaml but forgot the set_file_name call; renaming yaml files without updating the caller; assuming load_meta_data takes the file name as an argument instead of using the global.","solutions":["Call set_file_name('your_file.yaml') before load_meta_data().","Confirm the file exists at metagpt/ext/spo/settings/your_file.yaml (exact name, .yaml not .yml or vice versa).","If using a custom location, copy/symlink the yaml into the settings directory or adjust the path resolution."],"exampleFix":"// before\nfrom metagpt.ext.spo.utils.load import load_meta_data\ndata = load_meta_data()  # FILE_NAME is \"\" -> path does not exist\n\n// after\nfrom metagpt.ext.spo.utils.load import set_file_name, load_meta_data\nset_file_name(\"CodeGeneration.yaml\")\ndata = load_meta_data()","handlingStrategy":"validation","validationCode":"from pathlib import Path\nfrom metagpt.ext.spo.utils import load\n\ndef settings_file_ready(name: str) -> bool:\n    p = Path(load.__file__).parent.parent / \"settings\" / name\n    return p.is_file()\n\nassert settings_file_ready(\"CodeGeneration.yaml\"), \"settings yaml missing\"","typeGuard":null,"tryCatchPattern":"try:\n    data = load_meta_data()\nexcept FileNotFoundError as e:\n    raise FileNotFoundError(f\"check set_file_name + metagpt/ext/spo/settings/: {e}\") from e","preventionTips":["Set FILE_NAME immediately at process start, next to config loading.","Assert the settings file exists in a startup check before launching long SPO runs."],"tags":["configuration","spo","file-not-found","yaml"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}