{"record":{"id":"185e75024cf62b53","repo":"sgl-project/sglang","slug":"no-valid-gpu-mappings-found-in-json","errorCode":null,"errorMessage":"No valid GPU mappings found in JSON","messagePattern":"No valid GPU mappings found in JSON","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/distributed/device_communicators/mooncake_transfer_engine.py","lineNumber":72,"sourceCode":"            raise ValueError(f\"Invalid JSON mapping: {normalized_input}\") from exc\n\n    if not isinstance(mapping, dict):\n        raise ValueError(\n            \"Invalid format: expected a mapping from GPU id to IB device string\"\n        )\n\n    normalized_mapping: Dict[int, str] = {}\n    for gpu_key, ib_devices in mapping.items():\n        normalized_key = int(gpu_key) if str(gpu_key).isdigit() else None\n        if normalized_key is None or not isinstance(ib_devices, str):\n            raise ValueError(\n                \"Invalid format: keys must be integers (or string \"\n                \"representations of integers) and values must be strings\"\n            )\n        normalized_mapping[normalized_key] = ib_devices.strip()\n\n    if not normalized_mapping:\n        raise ValueError(\"No valid GPU mappings found in JSON\")\n\n    return normalized_mapping\n\n\ndef get_ib_devices_for_gpu(ib_device_str: Optional[str], gpu_id: int) -> Optional[str]:\n    \"\"\"\n    Parse IB device string and get IB devices for a specific GPU ID.\n\n    Supports all the following formats:\n    1. Old format: \"ib0, ib1, ib2\"\n    2. New format: {0: \"ib0, ib1\", 1: \"ib2, ib3\", 2: \"ib4\"}\n    3. JSON file: path to a JSON file containing the mapping\n\n    Args:\n        ib_device_str: The original IB device string or path to JSON file\n        gpu_id: The GPU ID to get devices for\n\n    Returns:","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/distributed/device_communicators/mooncake_transfer_engine.py#L54-L90","documentation":"The parsed mapping dict passed key/value validation but normalized to an empty dict — i.e. the JSON object contained no entries ({}), so there are no GPU->IB-device pairs to use. parse_ib_device_config raises ValueError('No valid GPU mappings found in JSON').","triggerScenarios":"Supplying an empty JSON object '{}' (inline or as file contents) as the IB-device config; since invalid entries raise earlier, this is specifically the zero-entries case.","commonSituations":"Deploying an empty template mapping file that was never populated.","solutions":["Populate the mapping with at least one GPU id to IB device pair covering the GPUs in use","Or remove the JSON config and pass the plain IB device string / leave unset if defaults suffice"],"exampleFix":"# before (gpu_ib_map.json)\n{}\n\n# after\n{\"0\": \"mlx5_0\", \"1\": \"mlx5_1\"}","handlingStrategy":"validation","validationCode":"import json\n\ndef assert_nonempty_mapping(path: str) -> None:\n    m = json.load(open(path))\n    assert isinstance(m, dict) and len(m) > 0, \"IB mapping must contain at least one entry\"","typeGuard":null,"tryCatchPattern":"try:\n    parse_ib_device_config(cfg)\nexcept ValueError as e:\n    if \"No valid GPU mappings\" in str(e):\n        raise ConfigError(\"IB mapping is empty; populate GPU->device pairs\") from e\n    raise","preventionTips":["Never ship an empty '{}' template; CI-validate that the mapping has entries","Default to the plain device-string form when per-GPU mapping is unnecessary"],"tags":["json","config","empty-config","mooncake"],"backgroundTag":"empty-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}