{"record":{"id":"7262bc278e6b03a2","repo":"FoundationAgents/MetaGPT","slug":"target-column-not-provided","errorCode":null,"errorMessage":"Target column not provided","messagePattern":"Target column not provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/ext/sela/data/dataset.py","lineNumber":319,"sourceCode":"        with open(Path(self.dataset_dir, self.name, \"dataset_info.json\"), \"w\", encoding=\"utf-8\") as file:\n            # utf-8 encoding is required\n            json.dump(dataset_info, file, indent=4, ensure_ascii=False)\n\n    def save_split_datasets(self, df, split, target_col=None):\n        path = Path(self.dataset_dir, self.name)\n        df.to_csv(Path(path, f\"split_{split}.csv\"), index=False)\n        if target_col:\n            df_wo_target = df.drop(columns=[target_col])\n            df_wo_target.to_csv(Path(path, f\"split_{split}_wo_target.csv\"), index=False)\n            df_target = df[[target_col]].copy()\n            if target_col != \"target\":\n                df_target[\"target\"] = df_target[target_col]\n                df_target = df_target.drop(columns=[target_col])\n            df_target.to_csv(Path(path, f\"split_{split}_target.csv\"), index=False)\n\n    def split_and_save(self, df, target_col, test_df=None):\n        if not target_col:\n            raise ValueError(\"Target column not provided\")\n        if test_df is None:\n            train, test = train_test_split(df, test_size=1 - TRAIN_TEST_SPLIT, random_state=SEED)\n        else:\n            train = df\n            test = test_df\n        train, dev = train_test_split(train, test_size=1 - TRAIN_DEV_SPLIT, random_state=SEED)\n        self.save_split_datasets(train, \"train\")\n        self.save_split_datasets(dev, \"dev\", target_col)\n        self.save_split_datasets(test, \"test\", target_col)\n\n\nclass OpenMLExpDataset(ExpDataset):\n    def __init__(self, name, dataset_dir, dataset_id, **kwargs):\n        self.dataset_id = dataset_id\n        self.dataset = openml.datasets.get_dataset(\n            self.dataset_id, download_data=False, download_qualities=False, download_features_meta_data=True\n        )\n        self.name = self.dataset.name","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/ext/sela/data/dataset.py#L301-L337","documentation":"Raised by ExpDataset.split_and_save when target_col is falsy (None or empty string). Splits need the target column to emit the *_wo_target.csv and *_target.csv side files used by SELA evaluation, so train/dev/test cannot be saved without it.","triggerScenarios":"Calling split_and_save(df, None) or save_dataset(target_col=None), typically when the dataset entry in datasets.yaml lacks a target_col.","commonSituations":"Custom dataset registered in config without target_col; programmatic use of ExpDataset where the caller forgot to pass the column.","solutions":["Provide the correct target column name (string) for the dataset","Add 'target_col' to the dataset's entry in datasets.yaml so save_dataset receives it","Verify the column name exists in the raw train.csv header"],"exampleFix":"# before\ndataset.split_and_save(df, target_col=None)\n\n# after\ndataset.split_and_save(df, target_col=\"class\")","handlingStrategy":"validation","validationCode":"assert target_col, \"target column required\"\nassert target_col in df.columns","typeGuard":"def has_target_col(target_col) -> bool:\n    return isinstance(target_col, str) and bool(target_col)","tryCatchPattern":null,"preventionTips":["Always fill target_col in the dataset config","Confirm the column exists in the raw csv header"],"tags":["sela","dataset","validation","config"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}