{"record":{"id":"a41f7afaabffdd6d","repo":"hyperledger/fabric","slug":"failed-to-extract-payload-from-config-envelope","errorCode":null,"errorMessage":"failed to extract payload from config envelope","messagePattern":"failed to extract payload from config envelope","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/consensus/etcdraft/util.go","lineNumber":193,"sourceCode":"\n// ConsensusMetadataFromConfigBlock reads consensus metadata updates from the configuration block\nfunc ConsensusMetadataFromConfigBlock(block *common.Block) (*etcdraft.ConfigMetadata, *orderer.ConsensusType, error) {\n\tif block == nil {\n\t\treturn nil, nil, errors.New(\"nil block\")\n\t}\n\n\tif !protoutil.IsConfigBlock(block) {\n\t\treturn nil, nil, errors.New(\"not a config block\")\n\t}\n\n\tconfigEnvelope, err := ConfigEnvelopeFromBlock(block)\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"cannot read config update\")\n\t}\n\n\tpayload, err := protoutil.UnmarshalPayload(configEnvelope.GetPayload())\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"failed to extract payload from config envelope\")\n\t}\n\t// get config update\n\tconfigUpdate, err := configtx.UnmarshalConfigUpdateFromPayload(payload)\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"could not read config update\")\n\t}\n\n\treturn MetadataFromConfigUpdate(configUpdate)\n}\n\n// VerifyConfigMetadata validates Raft config metadata.\n// Note: ignores certificates expiration.\nfunc VerifyConfigMetadata(metadata *etcdraft.ConfigMetadata, verifyOpts x509.VerifyOptions) error {\n\tif metadata == nil {\n\t\t// defensive check. this should not happen as CheckConfigMetadata\n\t\t// should always be called with non-nil config metadata\n\t\treturn errors.Errorf(\"nil Raft config metadata\")\n\t}","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/consensus/etcdraft/util.go#L175-L211","documentation":"After the config envelope is obtained, ConsensusMetadataFromConfigBlock unmarshals its payload with protoutil.UnmarshalPayload. This error means the envelope's Payload bytes are empty or not valid protobuf — the config envelope itself is malformed even though it was extracted successfully.","triggerScenarios":"Envelope at block index 0 has a nil/empty or corrupted Payload field while still being extractable as an Envelope; bit-rot or truncation in stored block data.","commonSituations":"Disk corruption on the ordering node's ledger; blocks copied between nodes/filesystems incorrectly; synthetic test envelopes with unset Payload.","solutions":["Re-fetch the config block from another ordering node or an on-demand backup to replace the corrupted data.","Verify the envelope was constructed with marshaled Payload bytes (protoutil.MarshalOrPanic on a common.Payload) before insertion in tests.","Check ledger storage integrity (filelocks, filesystem errors) and consider rebuilding the node from a snapshot if corruption recurs."],"exampleFix":"// before\nenv := &common.Envelope{Signature: sig} // Payload left nil\n\n// after\npayload := protoutil.MarshalOrPanic(&common.Payload{Header: hdr, Data: configData})\nenv := &common.Envelope{Payload: payload, Signature: sig}","handlingStrategy":"validation","validationCode":"if len(configEnvelope.GetPayload()) == 0 {\n    return errors.New(\"config envelope has empty payload\")\n}","typeGuard":"func hasPayload(envelope *common.Envelope) bool {\n    return envelope != nil && len(envelope.GetPayload()) > 0\n}","tryCatchPattern":"meta, _, err := ConsensusMetadataFromConfigBlock(block)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to extract payload from config envelope\") {\n        return errors.Wrap(err, \"corrupt config envelope payload; restore block from backup\")\n    }\n    return err\n}","preventionTips":["Construct envelopes with marshaled Payload bytes only (protoutil.MarshalOrPanic).","Check payload length before parsing when handling externally supplied blocks.","Investigate storage/filesystem health if payload unmarshal failures persist."],"tags":["hyperledger-fabric","etcdraft","block-parsing","protobuf"],"backgroundTag":"malformed-block-envelope","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"}