{"record":{"id":"80f1601c2f9901e4","repo":"huggingface/open-r1","slug":"datasets-must-be-a-list-of-dataset-configuration","errorCode":null,"errorMessage":"'datasets' must be a list of dataset configurations","messagePattern":"'datasets' must be a list of dataset configurations","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/open_r1/configs.py","lineNumber":104,"sourceCode":"                    \"Expected format: {'datasets': [...], 'seed': int}\"\n                )\n\n            datasets_list = []\n            datasets_data = self.dataset_mixture.get(\"datasets\", [])\n\n            if isinstance(datasets_data, list):\n                for dataset_config in datasets_data:\n                    datasets_list.append(\n                        DatasetConfig(\n                            id=dataset_config.get(\"id\"),\n                            config=dataset_config.get(\"config\"),\n                            split=dataset_config.get(\"split\", \"train\"),\n                            columns=dataset_config.get(\"columns\"),\n                            weight=dataset_config.get(\"weight\", 1.0),\n                        )\n                    )\n            else:\n                raise ValueError(\"'datasets' must be a list of dataset configurations\")\n\n            self.dataset_mixture = DatasetMixtureConfig(\n                datasets=datasets_list,\n                seed=self.dataset_mixture.get(\"seed\", 0),\n                test_split_size=self.dataset_mixture.get(\"test_split_size\", None),\n            )\n\n            # Check that column names are consistent across all dataset configs\n            columns_sets = [set(dataset.columns) for dataset in datasets_list if dataset.columns is not None]\n            if columns_sets:\n                first_columns = columns_sets[0]\n                if not all(columns == first_columns for columns in columns_sets):\n                    raise ValueError(\n                        \"Column names must be consistent across all dataset configurations in a mixture. \"\n                        f\"Found different column sets: {[list(cols) for cols in columns_sets]}\"\n                    )\n\n","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/huggingface/open-r1/blob/1416fa0cf21595d2083b399a2a0bbddd7f6e9563/src/open_r1/configs.py#L86-L122","documentation":"Inside dataset_mixture, the value under the 'datasets' key must be a list of per-dataset configuration dicts. If it is any other type (string, dict, number), __post_init__ raises this ValueError because it iterates the list and reads keys like id/config/split/columns/weight from each element.","triggerScenarios":"dataset_mixture={\"datasets\": \"my_dataset\"} or {\"datasets\": {\"id\": ...}} — 'datasets' present but not a list of dicts.","commonSituations":"Passing a single dataset id string instead of a list; nesting the mixture dict one level too deep; JSON configs where datasets was a mapping of name->config.","solutions":["Make 'datasets' a list of dicts: {\"datasets\": [{\"id\": \"org/name\", \"split\": \"train\"}]}.","If you only have one dataset, wrap it in a single-element list.","Validate the JSON/YAML structure parses to a list, not a string or object."],"exampleFix":"// before\ndataset_mixture={\"datasets\": {\"id\": \"org/name\"}}  # dict, not list\n// after\ndataset_mixture={\"datasets\": [{\"id\": \"org/name\", \"config\": \"default\", \"split\": \"train\", \"weight\": 1.0}]}","handlingStrategy":"type-guard","validationCode":"ds = (mixture or {}).get(\"datasets\")\nif ds is not None and not (isinstance(ds, list) and all(isinstance(d, dict) for d in ds)):\n    raise ValueError(\"'datasets' must be a list of dicts\")","typeGuard":"def is_dataset_spec_list(v) -> bool:\n    return isinstance(v, list) and all(isinstance(d, dict) and \"id\" in d for d in v)","tryCatchPattern":"try:\n    cfg = DatasetConfig(dataset_mixture=mixture)\nexcept ValueError as e:\n    if \"must be a list of dataset configurations\" in str(e):\n        sys.exit(\"Fix dataset_mixture.datasets: wrap each dataset spec in a list of dicts\")\n    raise","preventionTips":["Wrap single datasets in a list: [{\"id\": ...}]","Each spec needs at least an 'id' key; optional config/split/columns/weight","Validate JSON/YAML structure with a schema (e.g. jsonschema) before training"],"tags":["python","configuration","schema","datasets"],"backgroundTag":"schema-validation-failed","analyzedSha":"1416fa0cf21595d2083b399a2a0bbddd7f6e9563","analyzedAt":"2026-08-30T08:56:53.400Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}