{"record":{"id":"5aad9894d290c9a6","repo":"keras-team/keras","slug":"unsupported-npy-file-version-version","errorCode":null,"errorMessage":"Unsupported `.npy` file version: {version}.","messagePattern":"Unsupported `\\.npy` file version: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/datasets/npz_utils.py","lineNumber":67,"sourceCode":"    \"\"\"\n    try:\n        # Fast path: numeric arrays load with pickle fully disabled.\n        return np.lib.format.read_array(fp, allow_pickle=False)\n    except ValueError:\n        # Object array: rewind, skip the header, then restrict the unpickler.\n        fp.seek(0)\n        version = np.lib.format.read_magic(fp)\n        if version[0] == 1:\n            np.lib.format.read_array_header_1_0(fp)\n        elif version[0] in (2, 3):\n            # numpy exposes no public `read_array_header_3_0`. The 3.0 format\n            # only differs from 2.0 by encoding the header string as UTF-8\n            # instead of latin1; the 4-byte header-length layout we skip past\n            # to reach the pickle stream is identical, so 2.0's reader handles\n            # both.\n            np.lib.format.read_array_header_2_0(fp)\n        else:\n            raise ValueError(f\"Unsupported `.npy` file version: {version}.\")\n        return RestrictedUnpickler(fp).load()\n\n\ndef load_npz(path):\n    \"\"\"Safely load an `.npz` archive into a `dict` of arrays.\n\n    This is a drop-in replacement for `np.load(path, allow_pickle=True)` for\n    the built-in datasets that store ragged object arrays. Unlike\n    `allow_pickle=True`, it only ever unpickles numpy arrays, so loading a\n    maliciously crafted file cannot execute arbitrary code.\n\n    Args:\n        path: Path to the `.npz` file.\n\n    Returns:\n        A `dict` mapping each member name to its array.\n    \"\"\"\n    arrays = {}","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/datasets/npz_utils.py#L49-L85","documentation":"Error \"Unsupported `.npy` file version: {version}.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/datasets/npz_utils.py:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}