{"record":{"id":"3e8b0afebaafb1f1","repo":"jax-ml/jax","slug":"malformed-pickled-getattrkey-expected-1-tuple","errorCode":null,"errorMessage":"Malformed pickled GetAttrKey, expected 1-tuple","messagePattern":"Malformed pickled GetAttrKey, expected 1-tuple","errorType":"exception","errorClass":"XlaRuntimeError","httpStatus":null,"severity":"error","filePath":"jaxlib/pytree.cc","lineNumber":1977,"sourceCode":"    }\n    new (&key) DictKey(nb::cast<nb::object>(state[0]));\n  });\n\n  nb::class_<GetAttrKey> get_attr_key(\n      pytree, \"GetAttrKey\", nb::sig(\"class GetAttrKey(typing.Hashable)\"));\n  get_attr_key.def(nb::init<nb::str>(), nb::arg(\"name\"));\n  get_attr_key.def(\"__str__\", &GetAttrKey::ToString);\n  get_attr_key.def(\"__repr__\", &GetAttrKey::ToReprString);\n  get_attr_key.def(\"__eq__\", &GetAttrKey::Equals);\n  get_attr_key.def(\"__hash__\",\n                   [](const GetAttrKey& key) { return nb::hash(key.name()); });\n  get_attr_key.def_prop_ro(\"name\", &GetAttrKey::name);\n  get_attr_key.def_prop_ro_static(\"__match_args__\", &GetAttrKey::MatchArgs);\n  get_attr_key.def(\"__getstate__\",\n                   [](GetAttrKey& key) { return nb::make_tuple(key.name()); });\n  get_attr_key.def(\"__setstate__\", [](GetAttrKey& key, const nb::tuple& state) {\n    if (state.size() != 1) {\n      throw xla::XlaRuntimeError(\n          \"Malformed pickled GetAttrKey, expected 1-tuple\");\n    }\n    new (&key) GetAttrKey(nb::str(state[0]));\n  });\n\n  nb::class_<FlattenedIndexKey> flattened_index_key(\n      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);","sourceCodeStart":1959,"sourceCodeEnd":1995,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jaxlib/pytree.cc#L1959-L1995","documentation":"GetAttrKey.__setstate__ requires a 1-tuple state containing the attribute name string. Any other length is malformed.","triggerScenarios":"Unpickling a jaxlib.pytree.GetAttrKey with a state tuple of length != 1.","commonSituations":"Incompatible jaxlib versions between pickle producer and consumer; hand-crafted state.","solutions":["Re-create pickles with matching jaxlib versions","Do not modify pickle state tuples"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def valid_getattr_key_state(s) -> bool:\n    return isinstance(s, tuple) and len(s) == 1 and isinstance(s[0], str)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep jaxlib versions aligned when pickling treedef paths"],"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"}