{"record":{"id":"0963da8118052e2b","repo":"hyperledger/fabric","slug":"error-unmarshalling-metadata-for-key-s","errorCode":null,"errorMessage":"error unmarshalling metadata for key %s","messagePattern":"error unmarshalling metadata for key (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/serializer.go","lineNumber":485,"sourceCode":"\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}\n\t\tresult[name] = metadata\n\t}\n\treturn result, nil\n}\n","sourceCodeStart":467,"sourceCodeEnd":491,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/serializer.go#L467-L491","documentation":"Returned by Serializer.DeserializeAllMetadata when an entry in the metadata keyspace fails to proto-unmarshal into StateMetadata while scanning the whole namespace. One corrupt key aborts the range scan for all chaincode metadata under that namespace.","triggerScenarios":"Thrown at core/chaincode/lifecycle/serializer.go:485 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Identify the offending key from the wrapped error and repair/overwrite it","Re-commit lifecycle definitions to rewrite well-formed metadata"],"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"}