{"record":{"id":"80ebd6e83b0945ff","repo":"hyperledger/fabric","slug":"expected-key-s-to-encode-a-value-of-type-int64-b","errorCode":null,"errorMessage":"expected key %s to encode a value of type Int64, but was %T","messagePattern":"expected key (.+?) to encode a value of type Int64, but was %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/serializer.go","lineNumber":468,"sourceCode":"\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}\n\nfunc (s *Serializer) DeserializeAllMetadata(namespace string, state RangeableState) (map[string]*lb.StateMetadata, error) {\n\tprefix := fmt.Sprintf(\"%s/%s/\", namespace, MetadataInfix)\n\tkvs, err := state.GetStateRange(prefix)\n\tif err != nil {\n\t\treturn nil, errors.WithMessagef(err, \"could not get state range for namespace %s\", namespace)\n\t}\n\tresult := map[string]*lb.StateMetadata{}\n\tfor key, value := range kvs {\n\t\tname := key[len(prefix):]\n\t\tmetadata := &lb.StateMetadata{}\n\t\terr = proto.Unmarshal(value, metadata)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"error unmarshalling metadata for key %s\", key)\n\t\t}","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/serializer.go#L450-L486","documentation":"DeserializeFieldAsInt64 type guard: the lifecycle state at the field key decodes to a StateData oneof that is not Int64, so it cannot be returned as an integer (e.g. a sequence field holding a string).","triggerScenarios":"Thrown at core/chaincode/lifecycle/serializer.go:468 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure numeric fields (like sequence) were committed as Int64 values","Re-commit the chaincode definition with the correct field type"],"exampleFix":null,"handlingStrategy":"type-guard","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"}