{"record":{"id":"abde9352a2c0943e","repo":"jax-ml/jax","slug":"malformed-pickled-flattenedindexkey-expected-1-tu","errorCode":null,"errorMessage":"Malformed pickled FlattenedIndexKey, expected 1-tuple","messagePattern":"Malformed pickled FlattenedIndexKey, expected 1-tuple","errorType":"exception","errorClass":"XlaRuntimeError","httpStatus":null,"severity":"error","filePath":"jaxlib/pytree.cc","lineNumber":2002,"sourceCode":"      pytree, \"FlattenedIndexKey\",\n      nb::sig(\"class FlattenedIndexKey(typing.Hashable)\"));\n  flattened_index_key.def(nb::init<int>(), nb::arg(\"key\"));\n  flattened_index_key.def(\"__str__\", &FlattenedIndexKey::ToString);\n  flattened_index_key.def(\"__repr__\", &FlattenedIndexKey::ToReprString);\n  flattened_index_key.def(\"__eq__\", &FlattenedIndexKey::Equals);\n  flattened_index_key.def(\"__hash__\", [](const FlattenedIndexKey& key) {\n    return key.key() + kFlattenedIndexKeyHashSalt;\n  });\n  flattened_index_key.def_prop_ro(\"key\", &FlattenedIndexKey::key);\n  flattened_index_key.def_prop_ro_static(\"__match_args__\",\n                                         &FlattenedIndexKey::MatchArgs);\n  flattened_index_key.def(\"__getstate__\", [](FlattenedIndexKey& key) {\n    return nb::make_tuple(key.key());\n  });\n  flattened_index_key.def(\n      \"__setstate__\", [](FlattenedIndexKey& key, const nb::tuple& state) {\n        if (state.size() != 1) {\n          throw xla::XlaRuntimeError(\n              \"Malformed pickled FlattenedIndexKey, expected 1-tuple\");\n        }\n        new (&key) FlattenedIndexKey(nb::cast<int>(state[0]));\n      });\n}\n\n}  // namespace jax\n","sourceCodeStart":1984,"sourceCodeEnd":2010,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jaxlib/pytree.cc#L1984-L2010","documentation":"FlattenedIndexKey.__setstate__ expects a 1-tuple with the integer flattened index. Any other tuple length is rejected.","triggerScenarios":"Unpickling a jaxlib.pytree.FlattenedIndexKey whose state tuple doesn't have exactly one element.","commonSituations":"Cross-version unpickling of treedef paths containing flattened index keys; manipulated pickle data.","solutions":["Regenerate the pickled objects under the current jaxlib","Keep jaxlib versions aligned across processes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def valid_flattened_index_key_state(s) -> bool:\n    return isinstance(s, tuple) and len(s) == 1 and isinstance(s[0], int)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate pickles under current jaxlib rather than patching state tuples"],"tags":["jax","pytree","pickle"],"backgroundTag":"pickle-format-mismatch","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}