{"record":{"id":"51148931e3dba18f","repo":"huggingface/transformers","slug":"it-looks-like-the-config-file-at-resolved-config","errorCode":null,"errorMessage":"It looks like the config file at '{resolved_config_file}' is not a valid JSON file.","messagePattern":"It looks like the config file at '(.+?)' is not a valid JSON file\\.","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"src/transformers/configuration_utils.py","lineNumber":838,"sourceCode":"            except Exception:\n                # For any other exception, we throw a generic error.\n                raise OSError(\n                    f\"Can't load the configuration of '{pretrained_model_name_or_path}'. If you were trying to load it\"\n                    \" from 'https://huggingface.co/models', make sure you don't have a local directory with the same\"\n                    f\" name. Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a directory\"\n                    f\" containing a {configuration_file} file\"\n                )\n\n        try:\n            if gguf_file:\n                config_dict = load_gguf_checkpoint(resolved_config_file, return_tensors=False)[\"config\"]\n            else:\n                # Load config dict\n                config_dict = cls._dict_from_json_file(resolved_config_file)\n\n            config_dict[\"_commit_hash\"] = commit_hash\n        except (json.JSONDecodeError, UnicodeDecodeError):\n            raise OSError(f\"It looks like the config file at '{resolved_config_file}' is not a valid JSON file.\")\n\n        if is_local:\n            logger.info(f\"loading configuration file {resolved_config_file}\")\n        else:\n            logger.info(f\"loading configuration file {configuration_file} from cache at {resolved_config_file}\")\n\n        # timm models are not saved with the model_type in the config file\n        if \"model_type\" not in config_dict and is_timm_config_dict(config_dict):\n            config_dict[\"model_type\"] = \"timm_wrapper\"\n\n        # Some checkpoints may contain the wrong model_type in the config file.\n        # Allow the user to override it but warn them that it might not work.\n        if \"model_type\" in kwargs and config_dict[\"model_type\"] != kwargs[\"model_type\"]:\n            logger.warning(\n                f\"{configuration_file} has 'model_type={config_dict['model_type']}' but you overrode \"\n                f\"it with 'model_type={kwargs['model_type']}'. This may lead to unexpected behavior.\"\n            )\n            config_dict[\"model_type\"] = kwargs[\"model_type\"]","sourceCodeStart":820,"sourceCodeEnd":856,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/configuration_utils.py#L820-L856","documentation":"OSError raised by from_pretrained when the resolved config file (config.json or gguf) cannot be parsed because it raises json.JSONDecodeError or UnicodeDecodeError. The file was found but its bytes are not valid JSON/text, so _dict_from_json_file fails.","triggerScenarios":"A truncated download (interrupted hub download leaving a partial file in the cache), a hand-edited config.json with a stray comma or trailing text, a config.json saved with a non-UTF-8 encoding, or a GGUF file that is not actually GGUF.","commonSituations":"Corrupted HF cache after a killed process; config.json edited via shell echo/heredoc introducing bad quotes; files synced through tools that mangled encoding; partial uploads to a repo.","solutions":["Open the resolved_config_file path from the message in an editor or `python -m json.tool` and fix the JSON syntax.","If the file came from the hub cache, delete that cache entry (or run `huggingface-cli download --force`) so it is re-downloaded cleanly.","Verify encoding: re-save the file as UTF-8 without BOM."],"exampleFix":"// before\n{\"model_type\": \"gpt2\", \"n_embd\": 768,}  # trailing comma -> OSError\n\n// after\n{\"model_type\": \"gpt2\", \"n_embd\": 768}","handlingStrategy":"validation","validationCode":"import json, pathlib\np = pathlib.Path(config_path)\ntry:\n    json.loads(p.read_text(encoding=\"utf-8\"))\nexcept (json.JSONDecodeError, UnicodeDecodeError) as e:\n    raise ValueError(f\"config {p} is corrupt: {e}\")  # re-download or fix before from_pretrained","typeGuard":null,"tryCatchPattern":"try:\n    AutoConfig.from_pretrained(path)\nexcept OSError as e:\n    if \"not a valid JSON file\" in str(e):\n        clear_cache_for(path)\n        AutoConfig.from_pretrained(path)  # re-download once","preventionTips":["Validate JSON with python -m json.tool after hand-editing config files.","Use huggingface-cli download for atomic downloads instead of interrupted direct fetches."],"tags":["json","config","corruption","from-pretrained"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}