hyperledger/fabric · error
empty block
Error message
empty block
What it means
Returned by deliverclient.ConfigFromBlock when the block, its Data, or its data array is empty/nil. It is the guard for 'this block cannot possibly contain a config envelope', used by callers to distinguish non-config blocks from parse failures.
Source
Thrown at common/deliverclient/util.go:22
SPDX-License-Identifier: Apache-2.0
*/
package deliverclient
import (
"github.com/hyperledger/fabric-protos-go-apiv2/common"
"github.com/hyperledger/fabric/common/configtx"
"github.com/hyperledger/fabric/protoutil"
"github.com/pkg/errors"
)
var ErrNotAConfig = errors.New("not a config block")
// ConfigFromBlock returns a ConfigEnvelope if exists, or a *ErrNotAConfig error.
// It may also return some other error in case parsing failed.
func ConfigFromBlock(block *common.Block) (*common.ConfigEnvelope, error) {
if block == nil || block.Data == nil || len(block.Data.Data) == 0 {
return nil, errors.New("empty block")
}
txn := block.Data.Data[0]
env, err := protoutil.GetEnvelopeFromBlock(txn)
if err != nil {
return nil, errors.WithStack(err)
}
payload, err := protoutil.UnmarshalPayload(env.Payload)
if err != nil {
return nil, errors.WithStack(err)
}
if block.Header.Number == 0 {
configEnvelope, err := configtx.UnmarshalConfigEnvelope(payload.Data)
if err != nil {
return nil, errors.Wrap(err, "invalid config envelope")
}
return configEnvelope, nil
}
if payload.Header == nil {View on GitHub (pinned to 2736b63f8f)
Solutions
- Pass a non-empty, well-formed block
- Re-fetch the block from the orderer/peer if it was truncated in transit
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at common/deliverclient/util.go:22 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/3f4dcb82481bbb65.
Report an issue: GitHub.