{"record":{"id":"b9d7bd311e45fc39","repo":"hyperledger/fabric","slug":"failed-unmarshalling-ordererblockmetadata","errorCode":null,"errorMessage":"failed unmarshalling OrdererBlockMetadata","messagePattern":"failed unmarshalling OrdererBlockMetadata","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"orderer/consensus/smartbft/util.go","lineNumber":136,"sourceCode":"\n\tconsensusConfigOptions, err := createSmartBftConfig(oc)\n\tif err != nil {\n\t\treturn types.Configuration{}, err\n\t}\n\n\treturn util.ConfigFromMetadataOptions(selfID, consensusConfigOptions)\n}\n\nfunc getViewMetadataFromBlock(block *cb.Block) (*smartbftprotos.ViewMetadata, error) {\n\tif block.Header.Number == 0 {\n\t\t// Genesis block has no prior metadata so we just return an un-initialized metadata\n\t\treturn new(smartbftprotos.ViewMetadata), nil\n\t}\n\n\tsignatureMetadata := protoutil.GetMetadataFromBlockOrPanic(block, cb.BlockMetadataIndex_SIGNATURES)\n\tordererMD := &cb.OrdererBlockMetadata{}\n\tif err := proto.Unmarshal(signatureMetadata.Value, ordererMD); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed unmarshalling OrdererBlockMetadata\")\n\t}\n\n\tvar viewMetadata smartbftprotos.ViewMetadata\n\tif err := proto.Unmarshal(ordererMD.ConsenterMetadata, &viewMetadata); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &viewMetadata, nil\n}\n\ntype request struct {\n\tsigHdr   *cb.SignatureHeader\n\tenvelope *cb.Envelope\n\tchHdr    *cb.ChannelHeader\n}\n\n// RequestInspector inspects incoming requests and validates serialized identity\ntype RequestInspector struct {","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/consensus/smartbft/util.go#L118-L154","documentation":"getViewMetadataFromBlock reads the SIGNATURES block metadata, unmarshals it as OrdererBlockMetadata, and on failure wraps the proto error as 'failed unmarshalling OrdererBlockMetadata'. This metadata carries the current SmartBFT view metadata; without it the node cannot determine view/sequence state for the block.","triggerScenarios":"bftSmartConsensusBuild during chain construction or getViewMetadataLastConfigSqnFromBlock when the block's SIGNATURES metadata was not produced by SmartBFT (e.g. blocks from a Raft channel, foreign/edited metadata, or corruption).","commonSituations":"Switching a channel from Raft to BFT without proper migration so blocks lack OrdererBlockMetadata, manual block editing/corruption, or a version mismatch where the metadata protobuf changed shape.","solutions":["Do not mix block metadata formats; ensure the channel was created/updated for SmartBFT properly (no in-place Raft-to-BFT metadata mixing)","Check ledger integrity; restore the channel from a snapshot if metadata is corrupted","Verify all orderers run compatible Fabric versions producing the same OrdererBlockMetadata proto","Re-create the channel with a fresh genesis block if migration was incorrect"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"sigMD := protoutil.GetMetadataFromBlockOrPanic(block, cb.BlockMetadataIndex_SIGNATURES)\nmd := &cb.OrdererBlockMetadata{}\nif proto.Unmarshal(sigMD.Value, md) != nil || md.ConsenterMetadata == nil {\n  return errors.New(\"block lacks valid SmartBFT OrdererBlockMetadata\")\n}","typeGuard":"func hasBFTMetadata(block *cb.Block) bool {\n  sigMD := protoutil.GetMetadataFromBlockOrPanic(block, cb.BlockMetadataIndex_SIGNATURES)\n  md := &cb.OrdererBlockMetadata{}\n  return proto.Unmarshal(sigMD.Value, md) == nil && md.ConsenterMetadata != nil\n}","tryCatchPattern":"vm, err := getViewMetadataFromBlock(block)\nif err != nil {\n  return fmt.Errorf(\"cannot build BFT chain from this block's metadata: %w\", err)\n}","preventionTips":["Don't switch consensus type on existing channels in-place; create new channels","Keep all orderers on compatible Fabric versions","Avoid tools that rewrite block metadata","Validate ledger snapshots before import"],"tags":["hyperledger-fabric","smartbft","protobuf","block-metadata"],"backgroundTag":"protobuf-unmarshal-failed","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"}