{"record":{"id":"74556740f8d8fffd","repo":"hyperledger/fabric","slug":"failed-to-unmarshal-block-s-metadata","errorCode":null,"errorMessage":"failed to unmarshal block's metadata","messagePattern":"failed to unmarshal block's metadata","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/consensus/etcdraft/consenter.go","lineNumber":281,"sourceCode":"\t}\n\n\tif _, err := c.detectSelfID(consenters); err != nil {\n\t\tif err != cluster.ErrNotInChannel {\n\t\t\treturn false, errors.Wrapf(err, \"failed to detect self ID by comparing public keys\")\n\t\t}\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}\n\n// ReadBlockMetadata attempts to read raft metadata from block metadata, if available.\n// otherwise, it reads raft metadata from config metadata supplied.\nfunc ReadBlockMetadata(blockMetadata *common.Metadata, configMetadata *etcdraft.ConfigMetadata) (*etcdraft.BlockMetadata, error) {\n\tif blockMetadata != nil && len(blockMetadata.GetValue()) != 0 { // we have consenters mapping from block\n\t\tm := &etcdraft.BlockMetadata{}\n\t\tif err := proto.Unmarshal(blockMetadata.GetValue(), m); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to unmarshal block's metadata\")\n\t\t}\n\t\treturn m, nil\n\t}\n\n\tm := &etcdraft.BlockMetadata{\n\t\tNextConsenterId: 1,\n\t\tConsenterIds:    make([]uint64, len(configMetadata.GetConsenters())),\n\t}\n\t// need to read consenters from the configuration\n\tfor i := range m.GetConsenterIds() {\n\t\tm.ConsenterIds[i] = m.GetNextConsenterId()\n\t\tm.NextConsenterId++\n\t}\n\n\treturn m, nil\n}\n\n// New creates a etcdraft Consenter","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/consensus/etcdraft/consenter.go#L263-L299","documentation":"ReadBlockMetadata wraps a proto.Unmarshal failure on the block's metadata value: the persisted block metadata (RAFT metadata in metadata slot) exists but is not a decodable etcdraft.BlockMetadata protobuf — corrupt or written by an incompatible version.","triggerScenarios":"Thrown at orderer/consensus/etcdraft/consenter.go:281 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the ledger/WAL from a healthy backup","Check for version skew if blocks were written by a different Fabric release"],"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"}