{"record":{"id":"1911f3548be8e937","repo":"hyperledger/fabric","slug":"failed-extracting-bundle-from-envelope","errorCode":null,"errorMessage":"failed extracting bundle from envelope","messagePattern":"failed extracting bundle from envelope","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/common/cluster/util.go","lineNumber":327,"sourceCode":"\t}\n\n\treturn string(rawJSON)\n}\n\n// EndpointconfigFromConfigBlock retrieves TLS CA certificates and endpoints\n// from a config block.\nfunc EndpointconfigFromConfigBlock(block *common.Block, bccsp bccsp.BCCSP) ([]EndpointCriteria, error) {\n\tif block == nil {\n\t\treturn nil, errors.New(\"nil block\")\n\t}\n\tenvelopeConfig, err := protoutil.ExtractEnvelope(block, 0)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbundle, err := channelconfig.NewBundleFromEnvelope(envelopeConfig, bccsp)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed extracting bundle from envelope\")\n\t}\n\tmsps, err := bundle.MSPManager().GetMSPs()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed obtaining MSPs from MSPManager\")\n\t}\n\tordererConfig, ok := bundle.OrdererConfig()\n\tif !ok {\n\t\treturn nil, errors.New(\"failed obtaining orderer config from bundle\")\n\t}\n\n\tmspIDsToCACerts := make(map[string][][]byte)\n\tvar aggregatedTLSCerts [][]byte\n\tfor _, org := range ordererConfig.Organizations() {\n\t\t// Validate that every orderer org has a corresponding MSP instance in the MSP Manager.\n\t\tmsp, exists := msps[org.MSPID()]\n\t\tif !exists {\n\t\t\treturn nil, errors.Errorf(\"no MSP found for MSP with ID of %s\", org.MSPID())\n\t\t}","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/cluster/util.go#L309-L345","documentation":"EndpointconfigFromConfigBlock parses the config block envelope into a channelconfig bundle (which contains the channel's organizations, MSPs, and orderer configuration). This error wraps any failure returned by channelconfig.NewBundleFromEnvelope — the envelope inside the block could not be interpreted as a valid channel configuration (bad proto, not a config transaction, unsupported structure). The wrap message adds context that the bundle extraction step specifically failed.","triggerScenarios":"Calling cluster.EndpointconfigFromConfigBlock(block, bccsp) with a block whose first envelope (protoutil.ExtractEnvelope(block, 0)) is not a valid, well-formed ConfigEnvelope — the block is not actually a config block, or its envelope payload is corrupted/truncated.","commonSituations":"Passing a regular (non-config) transaction block instead of a config block; pulling a block from the wrong channel so the payload does not match expectations; a corrupted or truncated block on disk; BCCSP crypto provider misconfiguration so signatures/payloads cannot be processed; Fabric version mismatch producing an unrecognized config structure.","solutions":["Verify the block is actually a config block (its data contains a ConfigEnvelope) — e.g., check protoutil.IsConfigBlock(block) before the call.","Read the wrapped inner error; if it is a proto unmarshal failure the block bytes are corrupt — re-pull the config block from a healthy orderer.","Ensure the block belongs to the intended channel; pull the latest config block via BlockPuller targeting the correct channel.","Check the BCCSP configuration (keystore, softvsHSM) of the node invoking the extraction.","Confirm the Fabric binary version is consistent across the network to avoid config-format incompatibilities."],"exampleFix":"// before\nblock := ledger.GetBlockByNumber(txBlockSeq) // regular tx block, not a config block\ncriteria, err := cluster.EndpointconfigFromConfigBlock(block, bccsp) // failed extracting bundle from envelope\n// after\nblock := ledger.GetBlockByNumber(latestSeq)\nif !protoutil.IsConfigBlock(block) {\n    block, err = puller.PullBlock(configSeq) // fetch an actual config block\n}\ncriteria, err := cluster.EndpointconfigFromConfigBlock(block, bccsp)","handlingStrategy":"validation","validationCode":"if !protoutil.IsConfigBlock(block) {\n    return nil, errors.New(\"block is not a config block; cannot extract endpoint config\")\n}\ncriteria, err := cluster.EndpointconfigFromConfigBlock(block, bccsp)","typeGuard":"func isValidConfigBlock(b *common.Block) bool {\n    if b == nil || b.Data == nil { return false }\n    env, err := protoutil.ExtractEnvelope(b, 0)\n    return err == nil && env != nil && protoutil.IsConfigBlock(b)\n}","tryCatchPattern":"criteria, err := cluster.EndpointconfigFromConfigBlock(block, bccsp)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed extracting bundle from envelope\") {\n        // inner err explains why; re-pull a fresh config block from a healthy orderer and retry\n        return errors.Wrap(err, \"config block unreadable; re-pull required\")\n    }\n    return err\n}","preventionTips":["Confirm the block is a config block (protoutil.IsConfigBlock) before extraction","Pull the latest config block from a healthy orderer rather than trusting local copies","Keep BCCSP crypto configuration valid and Fabric versions consistent across the network","Log the wrapped inner error to distinguish corruption from wrong-channel/wrong-block mistakes"],"tags":["hyperledger-fabric","orderer","config-block","envelope","bundle-parsing"],"backgroundTag":"config-envelope-invalid","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}