{"record":{"id":"5a7ec619c895ed11","repo":"hyperledger/fabric","slug":"nil-block-5a7ec6","errorCode":null,"errorMessage":"nil block","messagePattern":"nil block","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/common/server/util.go","lineNumber":45,"sourceCode":"func createLedgerFactory(conf *config.TopLevel, metricsProvider metrics.Provider) (blockledger.Factory, error) {\n\tld := conf.FileLedger.Location\n\tif ld == \"\" {\n\t\tlogger.Panic(\"Orderer.FileLedger.Location must be set\")\n\t}\n\n\tlogger.Debug(\"Ledger dir:\", ld)\n\tlf, err := fileledger.New(ld, metricsProvider)\n\tif err != nil {\n\t\treturn nil, errors.WithMessage(err, \"Error in opening ledger factory\")\n\t}\n\treturn lf, nil\n}\n\n// validateBootstrapBlock returns whether this block can be used as a bootstrap block.\n// A bootstrap block is a block of a system channel, and needs to have a ConsortiumsConfig.\nfunc validateBootstrapBlock(block *common.Block, bccsp bccsp.BCCSP) error {\n\tif block == nil {\n\t\treturn errors.New(\"nil block\")\n\t}\n\n\tif block.Data == nil || len(block.Data.Data) == 0 {\n\t\treturn errors.New(\"empty block data\")\n\t}\n\n\tfirstTransaction := &common.Envelope{}\n\tif err := proto.Unmarshal(block.Data.Data[0], firstTransaction); err != nil {\n\t\treturn errors.Wrap(err, \"failed extracting envelope from block\")\n\t}\n\n\tbundle, err := channelconfig.NewBundleFromEnvelope(firstTransaction, bccsp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, exists := bundle.ConsortiumsConfig()\n\tif !exists {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/server/util.go#L27-L63","documentation":"validateBootstrapBlock checks whether a block can serve as a bootstrap (system-channel) block when the orderer starts without a system channel. A nil block is immediately rejected with this error, since there is nothing to validate and channel bootstrapping cannot proceed.","triggerScenarios":"verifyNoSystemChannelJoinBlock / verifyNoSystemChannel pass a nil pointer — e.g. the join-block file read failed and the nil error was swallowed, or the caller passes a nil block reference into orderer bootstrap validation.","commonSituations":"Orderer started with a missing or unreadable bootstrap/join block file, an empty GENESIS provider file path, or calling JoinChannel/bootstrap APIs where the block-load error was ignored upstream.","solutions":["Provide a valid genesis block via the General.BootstrapMethod=file setting pointing to a non-empty block file","Regenerate the genesis block with configtxgen if the file is missing/empty","Fix the caller to propagate block-loading errors instead of passing a nil block onward"],"exampleFix":"// before: error ignored, nil block passed downstream\nblock, _ := readGenesisBlock(path)\nerr := validateBootstrapBlock(block, bccsp)\n\n// after: check load error explicitly\nblock, err := readGenesisBlock(path)\nif err != nil {\n\treturn fmt.Errorf(\"cannot read bootstrap block %s: %w\", path, err)\n}\nerr = validateBootstrapBlock(block, bccsp)","handlingStrategy":"type-guard","validationCode":"// Go: guard before validateBootstrapBlock\nif block == nil {\n    return errors.New(\"bootstrap block not loaded\")\n}\nif err := block.Validate(bccsp); err != nil {\n    return err\n}","typeGuard":"func isLoadedBlock(b *common.Block) bool {\n    return b != nil && b.Header != nil && b.Data != nil && len(b.Data.Data) > 0\n}","tryCatchPattern":"if err := validateBootstrapBlock(block, bccsp); err != nil {\n    if err.Error() == \"nil block\" {\n        return fmt.Errorf(\"bootstrap file unreadable or empty; regenerate with configtxgen\")\n    }\n    return err\n}","preventionTips":["Check existence and size of the bootstrap/join block file at orderer startup","Propagate errors from block readers instead of swallowing them into nil","Keep the FABRIC_CFG_PATH bootstrap file path validated in deployment manifests"],"tags":["hyperledger-fabric","orderer","bootstrap","nil-block"],"backgroundTag":"nil-config-block","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"}