{"record":{"id":"b1cc14d7a8dd04d4","repo":"sgl-project/sglang","slug":"failed-to-load-diffusers-config-from-file-path","errorCode":null,"errorMessage":"Failed to load diffusers config from {file_path}: {e}","messagePattern":"Failed to load diffusers config from (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py","lineNumber":474,"sourceCode":"):\n    return AutoConfig.from_pretrained(\n        model, trust_remote_code=trust_remote_code, revision=revision, **kwargs\n    )\n\n\ndef load_dict(file_path):\n    if not os.path.exists(file_path):\n        return {}\n    try:\n        # Load the config directly from the file\n        with open(file_path) as f:\n            config_dict: dict[str, Any] = json.load(f)\n        if \"_diffusers_version\" in config_dict:\n            config_dict.pop(\"_diffusers_version\")\n        # TODO(will): apply any overrides from inference args\n        return config_dict\n    except Exception as e:\n        raise RuntimeError(\n            f\"Failed to load diffusers config from {file_path}: {e}\"\n        ) from e\n\n\ndef _split_hf_subfolder(path: str) -> tuple[str, str | None]:\n    \"\"\"Split 'namespace/repo/subfolder' into (repo_id, subfolder), or return (path, None).\"\"\"\n    if os.path.isabs(path):\n        return path, None\n    parts = path.split(\"/\")\n    if len(parts) > 2:\n        return \"/\".join(parts[:2]), \"/\".join(parts[2:])\n    return path, None\n\n\ndef prepare_diffusers_component_path_for_loading(component_path: str) -> str:\n    \"\"\"Download component repos if needed and patch legacy flat ModelOpt configs.\"\"\"\n    if os.path.exists(component_path):\n        local_component_path = component_path","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py#L456-L492","documentation":"load_dict wraps all exceptions raised while reading/parsing a diffusers component config JSON (missing file, permission error, JSONDecodeError) into a RuntimeError with the offending path and cause.","triggerScenarios":"Calling load_customized or get_diffusers_component_config where the component config JSON path does not exist, is unreadable, or contains malformed JSON. The `except Exception` also swallows json.pop bugs on unexpected structures.","commonSituations":"Corrupted or partially downloaded HF cache snapshot; manually edited config.json with trailing commas; wrong subfolder name passed to component loading.","solutions":["Validate the file exists and parses: python -m json.tool <path>","If the HF cache snapshot is partial/corrupt, delete the model directory and re-download","Check the component/subfolder name passed to the loader matches the repo layout"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import json, os\nassert os.path.isfile(path)\njson.loads(open(path).read())  # dry parse","typeGuard":null,"tryCatchPattern":"try:\n    cfg = load_dict(path)\nexcept RuntimeError as e:\n    if 'Failed to load diffusers config' in str(e):\n        # re-download or fall back to default config\n        ...","preventionTips":["Validate JSON parses before loading","Use HF CLI for downloads so snapshots verify integrity"],"tags":["config","json","corrupt-cache"],"backgroundTag":"config-parse-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}