{"record":{"id":"c886ea443c61e30c","repo":"hyperledger/fabric","slug":"block-bytes-for-block-num-d-should-not-be-nil","errorCode":null,"errorMessage":"block bytes for block num = [%d] should not be nil here. The indexes for the block are already present","messagePattern":"block bytes for block num = \\[(.+?)\\] should not be nil here\\. The indexes for the block are already present","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/ledger/blkstorage/blockfile_mgr.go","lineNumber":440,"sourceCode":"\t}\n\n\tlogger.Infof(\"Start building index from block [%d] to last block [%d]\", nextIndexableBlock, mgr.blockfilesInfo.lastPersistedBlock)\n\n\t// open a blockstream to the file location that was stored in the index\n\tvar stream *blockStream\n\tif stream, err = newBlockStream(mgr.rootDir, startFileNum, int64(startOffset), endFileNum); err != nil {\n\t\treturn err\n\t}\n\tdefer stream.close()\n\tvar blockBytes []byte\n\tvar blockPlacementInfo *blockPlacementInfo\n\n\tif skipFirstBlock {\n\t\tif blockBytes, _, err = stream.nextBlockBytesAndPlacementInfo(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif blockBytes == nil {\n\t\t\treturn errors.Errorf(\"block bytes for block num = [%d] should not be nil here. The indexes for the block are already present\",\n\t\t\t\tlastBlockIndexed)\n\t\t}\n\t}\n\n\t// Should be at the last block already, but go ahead and loop looking for next blockBytes.\n\t// If there is another block, add it to the index.\n\t// This will ensure block indexes are correct, for example if peer had crashed before indexes got updated.\n\tblockIdxInfo := &blockIdxInfo{}\n\tfor {\n\t\tif blockBytes, blockPlacementInfo, err = stream.nextBlockBytesAndPlacementInfo(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif blockBytes == nil {\n\t\t\tbreak\n\t\t}\n\t\tinfo, err := extractSerializedBlockInfo(blockBytes)\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/ledger/blkstorage/blockfile_mgr.go#L422-L458","documentation":"syncIndex internal consistency check: while rebuilding the index the stream returned nil block bytes for a block whose index entries already exist — local block files and index are inconsistent (corruption or crash during indexing).","triggerScenarios":"Thrown at common/ledger/blkstorage/blockfile_mgr.go:440 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-bootstrap the peer from a snapshot or genesis to rebuild consistent state","Investigate disk corruption of the block files under the ledger directory"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}