{"record":{"id":"602703b3bf8549fe","repo":"hyperledger/fabric","slug":"could-not-unmarshal-key-s-to-t","errorCode":null,"errorMessage":"could not unmarshal key %s to %T","messagePattern":"could not unmarshal key (.+?) to %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/serializer.go","lineNumber":453,"sourceCode":"\t}\n\tif value.Type == nil {\n\t\treturn nil, nil\n\t}\n\toneOf, ok := value.Type.(*lb.StateData_Bytes)\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"expected key %s to encode a value of type []byte, but was %T\", FieldKey(namespace, name, field), value.Type)\n\t}\n\treturn oneOf.Bytes, nil\n}\n\nfunc (s *Serializer) DeserializeFieldAsProto(namespace, name, field string, state ReadableState, msg proto.Message) error {\n\tbin, err := s.DeserializeFieldAsBytes(namespace, name, field, state)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = proto.Unmarshal(bin, msg)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"could not unmarshal key %s to %T\", FieldKey(namespace, name, field), msg)\n\t}\n\treturn nil\n}\n\nfunc (s *Serializer) DeserializeFieldAsInt64(namespace, name, field string, state ReadableState) (int64, error) {\n\tvalue, err := s.DeserializeField(namespace, name, field, state)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif value.Type == nil {\n\t\treturn 0, nil\n\t}\n\toneOf, ok := value.Type.(*lb.StateData_Int64)\n\tif !ok {\n\t\treturn 0, errors.Errorf(\"expected key %s to encode a value of type Int64, but was %T\", FieldKey(namespace, name, field), value.Type)\n\t}\n\treturn oneOf.Int64, nil\n}","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/serializer.go#L435-L471","documentation":"Returned by Serializer.DeserializeFieldAsProto when proto.Unmarshal fails on the bytes fetched for a proto-typed field. The state bytes were retrieved and were []byte-typed, but do not decode into the target message — corrupt or wrong-version data.","triggerScenarios":"Thrown at core/chaincode/lifecycle/serializer.go:453 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the expected proto type matches what was serialized at that key","Re-commit the definition so the field is written with the correct proto payload"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}