{"record":{"id":"3520c51dd9d6537a","repo":"sgl-project/sglang","slug":"model-index-json-does-not-contain-diffusers-versi","errorCode":null,"errorMessage":"model_index.json does not contain _diffusers_version","messagePattern":"model_index\\.json does not contain _diffusers_version","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py","lineNumber":711,"sourceCode":"    Returns:\n        The loaded model configuration as a dictionary\n    \"\"\"\n\n    # Check for model_index.json which is required for diffusers models\n    config_path = os.path.join(model_path, \"model_index.json\")\n    if not os.path.exists(config_path):\n        raise ValueError(\n            f\"Model directory {model_path} does not contain model_index.json. \"\n            \"Only HuggingFace diffusers format is supported.\"\n        )\n\n    # Load the config\n    with open(config_path) as f:\n        config = json.load(f)\n\n    # Verify diffusers version exists\n    if \"_diffusers_version\" not in config:\n        raise ValueError(\"model_index.json does not contain _diffusers_version\")\n\n    logger.info(\"Diffusers version: %s\", config[\"_diffusers_version\"])\n\n    component_keys = [\n        key\n        for key, value in config.items()\n        if isinstance(value, (list, tuple))\n        and len(value) == 2\n        and all(isinstance(item, str) for item in value)\n    ]\n    if component_keys:\n        missing_components = [\n            component_key\n            for component_key in component_keys\n            if not os.path.exists(os.path.join(model_path, component_key))\n        ]\n        if missing_components:\n            missing_str = \", \".join(missing_components)","sourceCodeStart":693,"sourceCodeEnd":729,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py#L693-L729","documentation":"After loading model_index.json, verify_model_config_and_directory checks it declares _diffusers_version, which diffusers always writes when saving a pipeline. Its absence means the JSON is not a genuine diffusers model_index (hand-written, stripped, or wrong file).","triggerScenarios":"Calling verify_model_config_and_directory on a directory whose model_index.json lacks the _diffusers_version key — e.g. a custom/minimal index or an older/edited snapshot.","commonSituations":"Hand-crafted model directories assembled from pieces; JSON sanitized by a deployment pipeline that dropped underscore-prefixed keys.","solutions":["Add \"_diffusers_version\": \"0.x.y\" matching the pipeline's target version to model_index.json","Re-download the model so the original model_index.json is restored"],"exampleFix":"// model_index.json (before) {\"_class_name\":\"FluxPipeline\"}\n// after {\"_class_name\":\"FluxPipeline\",\"_diffusers_version\":\"0.32.0\"}","handlingStrategy":"validation","validationCode":"cfg = json.load(open(f'{model_path}/model_index.json'))\nassert '_diffusers_version' in cfg","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't strip underscore-prefixed keys when processing model_index.json","Regenerate indexes with diffusers save_pretrained"],"tags":["diffusers","config-validation"],"backgroundTag":"config-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}