{"record":{"id":"842c9d527e6e7acb","repo":"hyperledger/fabric","slug":"channel-config-found-nil","errorCode":null,"errorMessage":"channel config found nil","messagePattern":"channel config found nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/peer/configtx_processor.go","lineNumber":38,"sourceCode":"\tchannelConfigKey = \"CHANNEL_CONFIG_ENV_BYTES\"\n\tpeerNamespace    = \"\"\n)\n\n// ConfigTxProcessor implements the interface 'github.com/hyperledger/fabric/core/ledger/customtx/Processor'\ntype ConfigTxProcessor struct{}\n\n// GenerateSimulationResults implements function in the interface 'github.com/hyperledger/fabric/core/ledger/customtx/Processor'\n// This implementation processes CONFIG transactions which simply stores the config-envelope-bytes\nfunc (tp *ConfigTxProcessor) GenerateSimulationResults(txEnv *common.Envelope, simulator ledger.TxSimulator, initializingLedger bool) error {\n\tpayload := protoutil.UnmarshalPayloadOrPanic(txEnv.Payload)\n\tchannelHdr := protoutil.UnmarshalChannelHeaderOrPanic(payload.Header.ChannelHeader)\n\ttxType := common.HeaderType(channelHdr.GetType())\n\n\tswitch txType {\n\tcase common.HeaderType_CONFIG:\n\t\tpeerLogger.Debugf(\"Processing CONFIG\")\n\t\tif payload.Data == nil {\n\t\t\treturn errors.New(\"channel config found nil\")\n\t\t}\n\t\treturn simulator.SetState(peerNamespace, channelConfigKey, payload.Data)\n\tdefault:\n\t\treturn fmt.Errorf(\"tx type [%s] is not expected\", txType)\n\t}\n}\n\nfunc retrieveChannelConfig(queryExecuter ledger.QueryExecutor) (*common.Config, error) {\n\tconfigBytes, err := queryExecuter.GetState(peerNamespace, channelConfigKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif configBytes == nil {\n\t\treturn nil, nil\n\t}\n\tconfigEnvelope := &common.ConfigEnvelope{}\n\tif err := proto.Unmarshal(configBytes, configEnvelope); err != nil {\n\t\treturn nil, err","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/peer/configtx_processor.go#L20-L56","documentation":"GenerateSimulationResults processes a transaction payload of type HeaderType_CONFIG during ledger simulation. The CONFIG payload's Data field is nil, so the channel config cannot be stored under the peer namespace; this sentinel error is returned.","triggerScenarios":"Calling GenerateSimulationResults with a txsim payload whose header type is CONFIG but whose Data byte slice is nil — i.e., a malformed/empty config payload passed to the processor.","commonSituations":"Constructing test config transactions manually and forgetting to serialize the Config message into payload.Data; a corrupted or truncated envelope that lost its data during channel creation; tooling that builds payloads programmatically (configtxgen-like flows).","solutions":["Ensure the CONFIG payload's Data contains the marshaled common.Config before calling GenerateSimulationResults.","Regenerate the channel creation/config transaction (e.g., via configtxgen) instead of hand-crafting the envelope.","Validate payload != nil and payload.Data != nil upstream before invoking the processor.","If from a fetched block, re-fetch the config block — the stored envelope may be corrupt."],"exampleFix":"// before\npayload := &common.Payload{Header: hdr} // Data nil\nsim.GenerateSimulationResults(payload)\n// after\ncfgBytes, _ := proto.Marshal(config)\npayload := &common.Payload{Header: hdr, Data: cfgBytes}\nsim.GenerateSimulationResults(payload)","handlingStrategy":"validation","validationCode":"if payload == nil || payload.Data == nil {\n  return errors.New(\"CONFIG payload data is nil\")\n}","typeGuard":"func hasConfigData(p *common.Payload) bool {\n  return p != nil && p.Data != nil\n}","tryCatchPattern":"if err := sim.GenerateSimulationResults(payload); err != nil && err.Error() == \"channel config found nil\" {\n  return fmt.Errorf(\"malformed CONFIG payload: %w\", err)\n}","preventionTips":["Use configtxgen-generated envelopes","Assert Data non-nil in tests","Validate imported block envelopes"],"tags":["ledger","config","payload-validation","hyperledger-fabric"],"backgroundTag":"nil-payload-data","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"}