{"record":{"id":"04e48f361c1567af","repo":"p-e-w/heretic","slug":"the-split-field-is-required-for-datasets-path","errorCode":null,"errorMessage":"The \"split\" field is required for datasets: {path}","messagePattern":"The \"split\" field is required for datasets: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/heretic/utils.py","lineNumber":189,"sourceCode":") -> list[Prompt]:\n    path = specification.dataset\n    split_str = specification.split\n\n    if os.path.isfile(path):\n        # Plain text file with one prompt per line. Empty lines are ignored.\n        with open(path, encoding=\"utf-8\") as file:\n            prompts = [line.strip() for line in file if line.strip()]\n\n        # The split is optional for text files. When given, it selects a subset\n        # of the lines using slice notation (e.g. \"[:400]\"). A synthetic split\n        # name is prepended because ReadInstruction expects a named split.\n        if split_str is not None:\n            start, end = get_split_slice(f\"_{split_str}\", len(prompts))\n            prompts = prompts[start:end]\n    else:\n        # All dataset sources require an explicit split and column.\n        if split_str is None:\n            raise ValueError(f'The \"split\" field is required for datasets: {path}')\n\n        if specification.column is None:\n            raise ValueError(f'The \"column\" field is required for datasets: {path}')\n\n        if is_hf_path(path):\n            # Pin to the latest commit if not already set, so the exact dataset\n            # version is recorded for reproducibility.\n            if specification.commit is None:\n                try:\n                    specification.commit = huggingface_hub.dataset_info(path).sha\n                except Exception as error:\n                    # Fetching the commit hash requires internet access, but the\n                    # dataset itself may be fully cached locally. Proceed without\n                    # pinning; an unpinned dataset disables the reproducibility\n                    # offer during upload.\n                    print(\n                        f\"[yellow]Warning: Could not fetch the latest commit hash for dataset [bold]{path}[/] ({error}). \"\n                        \"The dataset version will not be pinned.[/]\"","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/p-e-w/heretic/blob/bedb94ef117a271532ac2058447fbc165d5051bd/src/heretic/utils.py#L171-L207","documentation":"When loading prompts from a dataset source (as opposed to an inline source), the configuration must explicitly specify which split of the dataset to use. Datasets can have many splits and the library refuses to guess, so load_prompts raises this ValueError when the `split` field is missing.","triggerScenarios":"Configuring a prompt load whose path resolves to a dataset (HuggingFace or file dataset) without a `split` field in the specification.","commonSituations":"Copy-pasting an inline-prompts config that needed no split and pointing it at a HF dataset; assuming \"train\" is the default split.","solutions":["Add a `split` field to the dataset specification in your config (e.g. \"train\").","If the data is a small inline set, use an inline prompts source instead of a dataset path.","Verify the chosen split name exists in the dataset (e.g. train/validation/test)."],"exampleFix":"// before\n{\"dataset\": {\"path\": \"openai/gsm8k\"}}\n// after\n{\"dataset\": {\"path\": \"openai/gsm8k\", \"split\": \"test\", \"column\": \"question\"}}","handlingStrategy":"validation","validationCode":"cfg = spec[\"dataset\"]\nassert cfg.get(\"split\"), 'dataset config must include a \"split\" field'","typeGuard":"def dataset_config_is_complete(cfg: dict) -> bool:\n    return bool(cfg.get(\"split\")) and bool(cfg.get(\"column\"))","tryCatchPattern":"try:\n    prompts = load_prompts(specification)\nexcept ValueError as e:\n    if '\"split\" field is required' in str(e):\n        print(f\"Add split to dataset config for {specification.path}\")\n    else:\n        raise","preventionTips":["Always specify split (and column) for dataset sources.","Validate your prompt config schema before running experiments.","Check available splits with datasets.get_dataset_split_names()."],"tags":["python","configuration","datasets"],"backgroundTag":"missing-required-config-field","analyzedSha":"bedb94ef117a271532ac2058447fbc165d5051bd","analyzedAt":"2026-08-29T08:38:06.692Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}