{"record":{"id":"a24f3bf87a2cb925","repo":"huggingface/transformers","slug":"it-looks-like-the-config-file-at-is-not-a-val","errorCode":null,"errorMessage":"It looks like the config file at '{}' 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/generation/configuration_utils.py","lineNumber":1079,"sourceCode":"            except OSError:\n                # Raise any environment error raise by `cached_file`. It will have a helpful error message adapted to\n                # the original exception.\n                raise\n            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}'. 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}' is the correct path to a directory\"\n                    f\" containing a {configuration_file} file\"\n                )\n\n        try:\n            # Load config dict\n            config_dict = cls._dict_from_json_file(resolved_config_file)\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        if kwargs.get(\"_from_model_config\", False):\n            return cls.from_model_config(config_dict)\n        elif kwargs.get(\"return_unused_kwargs\") is True:\n            config, unused_kwargs = cls.from_dict(config_dict, **kwargs)\n            config._original_object_hash = hash(config)  # Hash to detect whether the instance was modified\n            return config, unused_kwargs\n        else:\n            config = cls.from_dict(config_dict, **kwargs)\n            config._original_object_hash = hash(config)  # Hash to detect whether the instance was modified\n            return config\n\n    @classmethod","sourceCodeStart":1061,"sourceCodeEnd":1097,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/generation/configuration_utils.py#L1061-L1097","documentation":"OSError from GenerationConfig.from_pretrained(): the file at resolved_config_file was located, but _dict_from_json_file() failed with json.JSONDecodeError or UnicodeDecodeError, meaning the bytes are not parseable JSON. This points at a corrupted download, a truncated file, an HTML error page cached with a .json name, or a hand-edited file with syntax errors.","triggerScenarios":"Interrupted download leaving a truncated generation_config.json in the HF cache; a proxy/portal returning HTML that got cached as the config; editing generation_config.json locally and leaving a trailing comma or single quotes; wrong-encoding file (UnicodeDecodeError).","commonSituations":"CI cache corruption; corporate proxies injecting login pages; manual config editing; disk-full during download.","solutions":["Inspect the file at the path in the message (e.g. cat it) to confirm corruption","Delete the cached file/directory and re-download: rm -rf ~/.cache/huggingface/hub/models--<org>--<name> or use huggingface-cli download --force","If you edited the file locally, validate it with python -m json.tool generation_config.json and fix syntax (double quotes, no trailing commas)","Check proxy/SSL interception if the content is HTML"],"exampleFix":"# before (truncated/invalid file)\ncfg = GenerationConfig.from_pretrained('./my_model')  # OSError: not valid JSON\n# after\n# shell: rm ~/.cache/huggingface/hub/models--org--my_model\n# or fix locally: python -m json.tool ./my_model/generation_config.json\ncfg = GenerationConfig.from_pretrained('./my_model')","handlingStrategy":"validation","validationCode":"import json, pathlib\np = pathlib.Path(local_dir) / 'generation_config.json'\nif p.exists():\n    json.loads(p.read_text())  # raises early with precise location if invalid","typeGuard":null,"tryCatchPattern":"try:\n    cfg = GenerationConfig.from_pretrained('./model')\nexcept OSError as e:\n    if 'not a valid JSON' in str(e):\n        subprocess.run(['rm','-rf', cache_dir])  # purge and re-download\n        cfg = GenerationConfig.from_pretrained('./model')\n    else:\n        raise","preventionTips":["Validate edited configs with python -m json.tool before use","Use huggingface-cli download for atomic downloads instead of interrupted manual fetches","Watch for proxy-injected HTML in cached files behind corporate networks"],"tags":["generation-config","json","cache","loading","corruption"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}