{"record":{"id":"11528a586518b8b0","repo":"sgl-project/sglang","slug":"failed-to-read-json-file-normalized-input-exc","errorCode":null,"errorMessage":"Failed to read JSON file {normalized_input}: {exc}","messagePattern":"Failed to read JSON file (.+?): (.+?)","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/distributed/device_communicators/mooncake_transfer_engine.py","lineNumber":47,"sourceCode":"    if ib_device_str is None or not ib_device_str.strip():\n        return None\n\n    normalized_input = ib_device_str.strip()\n    if not normalized_input.endswith(\".json\") and not normalized_input.startswith(\"{\"):\n        return normalized_input\n\n    if normalized_input.endswith(\".json\"):\n        if not os.path.isfile(normalized_input):\n            raise RuntimeError(f\"File {normalized_input} does not exist.\")\n        try:\n            with open(normalized_input, \"r\", encoding=\"utf-8\") as file:\n                mapping = json.load(file)\n        except json.JSONDecodeError as exc:\n            raise RuntimeError(\n                f\"Failed to parse JSON content from file {normalized_input}\"\n            ) from exc\n        except (IOError, OSError) as exc:\n            raise RuntimeError(\n                f\"Failed to read JSON file {normalized_input}: {exc}\"\n            ) from exc\n    else:\n        try:\n            mapping = json.loads(normalized_input)\n        except json.JSONDecodeError as exc:\n            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(","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/distributed/device_communicators/mooncake_transfer_engine.py#L29-L65","documentation":"The .json file exists and was opened, but reading it raised IOError/OSError before parsing completed — permissions denied, file removed between the isfile check and open, or an I/O error on the filesystem. parse_ib_device_config wraps the OS-level exception with the path and the original error text.","triggerScenarios":"The sglang process runs as a user without read permission on the mapping file, the file is deleted (race) after the existence check, or NFS/storage-level read errors occur on cluster nodes.","commonSituations":"Config file owned by root with 600 perms while the server runs as a non-root user, or a shared filesystem mount hiccup on one worker node.","solutions":["chmod a+r /path/to/gpu_ib_map.json (or chown to the serving user) on every node","Confirm the mount is healthy and the file readable from the serving user: sudo -u <user> cat <file>","Copy the mapping to local disk if a flaky network filesystem is the cause"],"exampleFix":"# before\n$ ls -l /etc/sglang/gpu_ib_map.json\n-rw------- 1 root root ...  # serving user can't read -> OSError\n\n# after\n$ sudo chmod 644 /etc/sglang/gpu_ib_map.json","handlingStrategy":"validation","validationCode":"import os\n\ndef check_readable(path: str) -> None:\n    if not os.access(path, os.R_OK):\n        raise PermissionError(f\"no read access to {path}\")","typeGuard":null,"tryCatchPattern":"try:\n    mapping = parse_ib_device_config(cfg)\nexcept RuntimeError as e:\n    if \"Failed to read JSON file\" in str(e):\n        fix_perms_and_retry(cfg)  # or re-provision file\n    raise","preventionTips":["Set mode 644 (or chown to the serving user) on config files in provisioning","Check readability as the actual serving user before launch","Prefer local disk over flaky network mounts for per-node configs"],"tags":["config","file-permissions","mooncake","io"],"backgroundTag":"file-read-permission-denied","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}