{"record":{"id":"e3a9787213150aa6","repo":"hyperledger/fabric","slug":"no-config-found-in-envelope","errorCode":null,"errorMessage":"no config found in envelope","messagePattern":"no config found in envelope","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/channelconfig/util.go","lineNumber":288,"sourceCode":"\t\tmspids = append(mspids, org.MSPID())\n\t}\n\treturn mspids, nil\n}\n\nfunc extractChannelConfig(block *cb.Block, bccsp bccsp.BCCSP) (*ChannelConfig, error) {\n\tenvelopeConfig, err := protoutil.ExtractEnvelope(block, 0)\n\tif err != nil {\n\t\treturn nil, errors.WithMessage(err, \"malformed configuration block\")\n\t}\n\n\tconfigEnv := &cb.ConfigEnvelope{}\n\t_, err = protoutil.UnmarshalEnvelopeOfType(envelopeConfig, cb.HeaderType_CONFIG, configEnv)\n\tif err != nil {\n\t\treturn nil, errors.WithMessage(err, \"malformed configuration envelope\")\n\t}\n\n\tif configEnv.Config == nil {\n\t\treturn nil, errors.New(\"no config found in envelope\")\n\t}\n\n\tif configEnv.Config.ChannelGroup == nil {\n\t\treturn nil, errors.New(\"no channel configuration found in the config block\")\n\t}\n\n\tif configEnv.Config.ChannelGroup.Groups == nil {\n\t\treturn nil, errors.New(\"no channel configuration groups are available\")\n\t}\n\n\t_, exists := configEnv.Config.ChannelGroup.Groups[ApplicationGroupKey]\n\tif !exists {\n\t\treturn nil, errors.Errorf(\"invalid configuration block, missing %s configuration group\", ApplicationGroupKey)\n\t}\n\n\tcc, err := NewChannelConfig(configEnv.Config.ChannelGroup, bccsp)\n\tif err != nil {\n\t\treturn nil, errors.WithMessage(err, \"no valid channel configuration found\")","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/channelconfig/util.go#L270-L306","documentation":"extractChannelConfig takes the config envelope embedded in a block and unmarshals it as a ConfigEnvelope of HeaderType_CONFIG. If the resulting envelope has a nil Config field, there is no usable config payload inside, so this error is returned. It guards downstream code that assumes configEnv.Config (and its ChannelGroup) exist.","triggerScenarios":"Calling ValidateCapabilities or ExtractMSPIDsForApplicationOrgs with a block/envelope whose payload is not a real CONFIG transaction — e.g. an empty payload, a config-update envelope without embedded config, or a corrupted/malformed block.","commonSituations":"Fetching the wrong index from a peer/orderer (an empty or non-config block instead of the latest config block); tooling constructing envelopes manually and leaving Config unset; truncated or corrupted ledger files.","solutions":["Pass the latest valid config block (e.g. fetched via the config block getter or delivered block with IsConfig()==true)","Verify the envelope contains HeaderType_CONFIG with a populated Config field","Re-fetch or repair the block source if the block itself is corrupted"],"exampleFix":"// before\nblock, _ := ledgerReader.Next() // arbitrary block\ncc, err := extractChannelConfig(block, bccsp)\n// after\nblock := configBlock // ensure IsConfig() / retrieved as latest config block\ncc, err := extractChannelConfig(block, bccsp)","handlingStrategy":"type-guard","validationCode":"func hasConfig(env *cb.Envelope) bool {\n\tpayload, err := protoutil.UnmarshalPayload(env.Payload)\n\tif err != nil || payload.Header == nil {\n\t\treturn false\n\t}\n\tch, err := protoutil.UnmarshalChannelHeader(payload.Header.ChannelHeader)\n\treturn err == nil && ch.Type == int32(cb.HeaderType_CONFIG)\n}","typeGuard":null,"tryCatchPattern":"cc, err := extractChannelConfig(block, bccsp)\nif err != nil {\n\tif strings.Contains(err.Error(), \"no config found in envelope\") {\n\t\treturn fmt.Errorf(\"block does not contain a config envelope; fetch the latest config block: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Only pass blocks known to be config blocks (IsConfig()==true or retrieved via a config-block query)","Validate the envelope type (HeaderType_CONFIG) before parsing","Guard against nil Config/ChannelGroup after unmarshalling in your own code"],"tags":["hyperledger-fabric","channelconfig","envelope","blocks"],"backgroundTag":"missing-config-in-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"}