{"record":{"id":"a64e9b53eac202f1","repo":"hiyouga/LlamaFactory","slug":"cannot-open-config-path-due-to-str-err","errorCode":null,"errorMessage":"Cannot open {config_path} due to {str(err)}.","messagePattern":"Cannot open (.+?) due to (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/data/parser.py","lineNumber":113,"sourceCode":"    if dataset_names is None:\n        dataset_names = []\n\n    if isinstance(dataset_dir, dict):\n        dataset_info = dataset_dir\n    elif dataset_dir == \"ONLINE\":\n        dataset_info = None\n    else:\n        if dataset_dir.startswith(\"REMOTE:\"):\n            config_path = hf_hub_download(repo_id=dataset_dir[7:], filename=DATA_CONFIG, repo_type=\"dataset\")\n        else:\n            config_path = os.path.join(dataset_dir, DATA_CONFIG)\n\n        try:\n            with open(config_path) as f:\n                dataset_info = json.load(f)\n        except Exception as err:\n            if len(dataset_names) != 0:\n                raise ValueError(f\"Cannot open {config_path} due to {str(err)}.\")\n\n            dataset_info = None\n\n    dataset_list: list[DatasetAttr] = []\n    for name in dataset_names:\n        if dataset_info is None:  # dataset_dir is ONLINE\n            load_from = \"ms_hub\" if use_modelscope() else \"om_hub\" if use_openmind() else \"hf_hub\"\n            dataset_attr = DatasetAttr(load_from, dataset_name=name)\n            dataset_list.append(dataset_attr)\n            continue\n\n        if name not in dataset_info:\n            raise ValueError(f\"Undefined dataset {name} in {DATA_CONFIG}.\")\n\n        has_hf_url = \"hf_hub_url\" in dataset_info[name]\n        has_ms_url = \"ms_hub_url\" in dataset_info[name]\n        has_om_url = \"om_hub_url\" in dataset_info[name]\n","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/data/parser.py#L95-L131","documentation":"Raised while loading dataset configuration: dataset_info.json cannot be opened or parsed at the resolved path (local dataset_dir or a REMOTE: hub download). If dataset names were requested, the unreadable config is fatal; with no names requested it is tolerated (dataset_info = None).","triggerScenarios":"Running train/api with dataset_dir pointing at a directory lacking dataset_info.json, a malformed JSON file, or REMOTE:repo where hf_hub_download fails (auth, network, missing file) while dataset_names is non-empty.","commonSituations":"Wrong dataset_dir path in YAML; JSON with trailing commas / comments; a dataset_dir set to the data file's folder instead of the config folder; hub outage or gated repo when using REMOTE:.","solutions":["Check the path exists and is valid JSON: `python -c \"import json;json.load(open('data/dataset_info.json'))\"`.","Fix dataset_dir in the YAML to the folder that actually contains dataset_info.json.","For REMOTE:, verify repo id, HF_TOKEN, and connectivity (huggingface-cli download <repo> dataset_info.json --repo-type dataset)."],"exampleFix":"### before\ndataset_dir: data/my_dataset  # no dataset_info.json here\ndataset: alpaca\n### after\ndataset_dir: data  # folder containing dataset_info.json with an 'alpaca' entry","handlingStrategy":"validation","validationCode":"import json, os\n\npath = os.path.join(dataset_dir, 'dataset_info.json')\nassert os.path.isfile(path), f'missing {path}'\njson.load(open(path))  # raises on malformed JSON before training starts","typeGuard":null,"tryCatchPattern":"try:\n    json.load(open(config_path))\nexcept (OSError, json.JSONDecodeError) as e:\n    raise SystemExit(f'dataset config unreadable: {config_path}: {e}') from e","preventionTips":["Validate dataset_info.json in CI or a preflight script.","Use absolute dataset_dir or paths relative to a fixed project root."],"tags":["dataset-config","json","file-io","hf-hub","config-path"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}