{"record":{"id":"e70d6fcab2ef2ee5","repo":"huggingface/open-r1","slug":"dataset-mixture-must-be-a-dictionary-with-a-datas","errorCode":null,"errorMessage":"dataset_mixture must be a dictionary with a 'datasets' key. Expected format: {'datasets': [...], 'seed': int}","messagePattern":"dataset_mixture must be a dictionary with a 'datasets' key\\. Expected format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/open_r1/configs.py","lineNumber":84,"sourceCode":"                test_split_size: 0.1\n    \"\"\"\n\n    # Override the dataset_name to make it optional\n    dataset_name: Optional[str] = field(\n        default=None, metadata={\"help\": \"Dataset name. Can be omitted if using dataset_mixture.\"}\n    )\n    dataset_mixture: Optional[dict[str, Any]] = field(\n        default=None,\n        metadata={\"help\": \"Configuration for creating dataset mixtures with advanced options like shuffling.\"},\n    )\n\n    def __post_init__(self):\n        if self.dataset_name is None and self.dataset_mixture is None:\n            raise ValueError(\"Either `dataset_name` or `dataset_mixture` must be provided\")\n\n        if self.dataset_mixture is not None:\n            if not isinstance(self.dataset_mixture, dict) or \"datasets\" not in self.dataset_mixture:\n                raise ValueError(\n                    \"dataset_mixture must be a dictionary with a 'datasets' key. \"\n                    \"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                    )","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/huggingface/open-r1/blob/1416fa0cf21595d2083b399a2a0bbddd7f6e9563/src/open_r1/configs.py#L66-L102","documentation":"When dataset_mixture is supplied it must be a dict containing a 'datasets' key (the expected format is {'datasets': [...], 'seed': int}). __post_init__ validates this and raises if the value is not a dict or lacks 'datasets', since the mixture-building code cannot proceed without the list of dataset specs.","triggerScenarios":"Passing dataset_mixture as a non-dict (e.g. a list of datasets directly, a string, or None-like value), or a dict that omits the 'datasets' key, e.g. dataset_mixture={\"seed\": 0}.","commonSituations":"Migrating from dataset_name to dataset_mixture and passing just a list of dataset IDs; YAML parsing turning the mixture into something unexpected; typo like 'dataset' instead of 'datasets'.","solutions":["Wrap the dataset list under a 'datasets' key: {\"datasets\": [{\"id\": \"org/name\", \"config\": \"default\", \"split\": \"train\"}], \"seed\": 42}.","Ensure dataset_mixture is a plain dict, not a list or string.","Fix typos in the 'datasets' key name."],"exampleFix":"// before\ndataset_mixture=[\"HuggingFaceH4/ultrachat_200k\"]  # not a dict -> ValueError\n// after\ndataset_mixture={\"datasets\": [{\"id\": \"HuggingFaceH4/ultrachat_200k\"}], \"seed\": 42}","handlingStrategy":"type-guard","validationCode":"if mixture is not None and (not isinstance(mixture, dict) or \"datasets\" not in mixture):\n    raise ValueError(\"dataset_mixture must be a dict with a 'datasets' key\")","typeGuard":"def is_valid_mixture(m) -> bool:\n    return isinstance(m, dict) and isinstance(m.get(\"datasets\"), list)","tryCatchPattern":"try:\n    cfg = DatasetConfig(dataset_mixture=mixture)\nexcept ValueError as e:\n    if \"'datasets' key\" in str(e):\n        mixture = {\"datasets\": mixture if isinstance(mixture, list) else [mixture], \"seed\": 0}\n        cfg = DatasetConfig(dataset_mixture=mixture)\n    else:\n        raise","preventionTips":["Follow the documented shape: {'datasets': [...], 'seed': int}","Never pass a bare list/string as dataset_mixture","Unit-test config loading from YAML before submitting jobs"],"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"}