hyperledger/fabric · error
channel config found nil
Error message
channel config found nil
What it means
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.
Source
Thrown at core/peer/configtx_processor.go:38
channelConfigKey = "CHANNEL_CONFIG_ENV_BYTES"
peerNamespace = ""
)
// ConfigTxProcessor implements the interface 'github.com/hyperledger/fabric/core/ledger/customtx/Processor'
type ConfigTxProcessor struct{}
// GenerateSimulationResults implements function in the interface 'github.com/hyperledger/fabric/core/ledger/customtx/Processor'
// This implementation processes CONFIG transactions which simply stores the config-envelope-bytes
func (tp *ConfigTxProcessor) GenerateSimulationResults(txEnv *common.Envelope, simulator ledger.TxSimulator, initializingLedger bool) error {
payload := protoutil.UnmarshalPayloadOrPanic(txEnv.Payload)
channelHdr := protoutil.UnmarshalChannelHeaderOrPanic(payload.Header.ChannelHeader)
txType := common.HeaderType(channelHdr.GetType())
switch txType {
case common.HeaderType_CONFIG:
peerLogger.Debugf("Processing CONFIG")
if payload.Data == nil {
return errors.New("channel config found nil")
}
return simulator.SetState(peerNamespace, channelConfigKey, payload.Data)
default:
return fmt.Errorf("tx type [%s] is not expected", txType)
}
}
func retrieveChannelConfig(queryExecuter ledger.QueryExecutor) (*common.Config, error) {
configBytes, err := queryExecuter.GetState(peerNamespace, channelConfigKey)
if err != nil {
return nil, err
}
if configBytes == nil {
return nil, nil
}
configEnvelope := &common.ConfigEnvelope{}
if err := proto.Unmarshal(configBytes, configEnvelope); err != nil {
return nil, errView on GitHub (pinned to 2736b63f8f)
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.
Example fix
// before
payload := &common.Payload{Header: hdr} // Data nil
sim.GenerateSimulationResults(payload)
// after
cfgBytes, _ := proto.Marshal(config)
payload := &common.Payload{Header: hdr, Data: cfgBytes}
sim.GenerateSimulationResults(payload) Defensive patterns
Strategy: validation
Validate before calling
if payload == nil || payload.Data == nil {
return errors.New("CONFIG payload data is nil")
} Type guard
func hasConfigData(p *common.Payload) bool {
return p != nil && p.Data != nil
} Try / catch
if err := sim.GenerateSimulationResults(payload); err != nil && err.Error() == "channel config found nil" {
return fmt.Errorf("malformed CONFIG payload: %w", err)
} Prevention
- Use configtxgen-generated envelopes
- Assert Data non-nil in tests
- Validate imported block envelopes
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- tx type [%s] is not expected
- organization %s not found
- error decoding the block number
- error decoding the data hash
- error decoding the previous hash
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/842c9d527e6e7acb.
Report an issue: GitHub.