hyperledger/fabric · error
no such blockNumber, transactionNumber <%d, %d> in index
Error message
no such blockNumber, transactionNumber <%d, %d> in index
What it means
blockIndex.getTXLocByBlockNumTranNum looks up the transaction location pointer stored in the index LevelDB under a key derived from (blockNum, tranNum). If the Get returns nil bytes, the (block, tx) pair is not present in the index and this error is thrown. It means the ledger index has no record for that transaction position.
Source
Thrown at common/ledger/blkstorage/blockindex.go:282
return nil, 0, errors.Wrapf(err, "unexpected error while unmarshalling bytes [%#v] into TxIDIndexValProto", valBytes)
}
blockNum, err := retrieveBlockNum(itr.Key(), len(rangeScan.startKey))
if err != nil {
return nil, 0, errors.WithMessage(err, "error while decoding block number from txID index key")
}
return val, blockNum, nil
}
func (index *blockIndex) getTXLocByBlockNumTranNum(blockNum uint64, tranNum uint64) (*fileLocPointer, error) {
if !index.isAttributeIndexed(IndexableAttrBlockNumTranNum) {
return nil, errors.New("<blockNumber, transactionNumber> tuple not maintained in index")
}
b, err := index.db.Get(constructBlockNumTranNumKey(blockNum, tranNum))
if err != nil {
return nil, err
}
if b == nil {
return nil, errors.Errorf("no such blockNumber, transactionNumber <%d, %d> in index", blockNum, tranNum)
}
txFLP := &fileLocPointer{}
if err := txFLP.unmarshal(b); err != nil {
return nil, err
}
return txFLP, nil
}
func (index *blockIndex) exportUniqueTxIDs(dir string, newHashFunc snapshot.NewHashFunc) (map[string][]byte, error) {
if !index.isAttributeIndexed(IndexableAttrTxID) {
return nil, errors.New("transaction IDs not maintained in index")
}
dbItr, err := index.db.GetIterator([]byte{txIDIdxKeyPrefix}, []byte{txIDIdxKeyPrefix + 1})
if err != nil {
return nil, err
}
defer dbItr.Release()View on GitHub (pinned to 2736b63f8f)
Solutions
- Verify the requested blockNum and tranNum are valid: blockNum < ledger height and tranNum < number of txs in that block.
- Check the ledger blockstorage indexConfig (ledger.blockstorage.indexConfig) includes indexableAttrBlockNumTranNum.
- Rebuild the block index if the ledger was restored from snapshot/backup with an incomplete index.
- Use the peer CLI (e.g. peer chaincode query or ledger inspect tools) to confirm the transaction actually committed.
Example fix
// before: blind lookup
loc, err := blkStorage.RetrieveTransactionByBlockNumTranNum(ledgerID, blockNum, txNum)
// after: bounds-check first
if blockNum >= bcInfo.Height {
return fmt.Errorf("block %d not committed (height=%d)", blockNum, bcInfo.Height)
}
loc, err := blkStorage.RetrieveTransactionByBlockNumTranNum(ledgerID, blockNum, txNum) Defensive patterns
Strategy: validation
Validate before calling
bcInfo, err := ledger.GetBlockchainInfo()
if err != nil { return err }
if blockNum >= bcInfo.Height {
return fmt.Errorf("block %d not present: ledger height is %d", blockNum, bcInfo.Height)
}
// additionally ensure tranNum < number of txs in block before lookup Try / catch
loc, err := retrieveTransactionByBlockNumTranNum(blockNum, tranNum)
if err != nil && strings.Contains(err.Error(), "no such blockNumber, transactionNumber") {
// treat as not-found, not as a system failure
return nil, ErrTransactionNotFound
}
if err != nil { return err } Prevention
- Bounds-check blockNum against ledger height and tranNum against the block's tx count before querying.
- Keep IndexableAttrBlockNumTranNum enabled in the blockstorage indexConfig.
- Validate ledger completeness after restoring from snapshot/backup before serving queries.
When it happens
Trigger: Calling retrieveTransactionByBlockNumTranNum with a block number or transaction number beyond what has been committed, or a transaction that exists in a block but was never indexed (index maintenance for the TXID/position attribute disabled).
Common situations: Querying a txNum >= blockDataCount, asking for a block higher than the ledger height, running with an index configuration that omits IndexableAttrBlockNumTranNum, or operating on a ledger restored from an incomplete/partial index.
Related errors
- error in block index: %s
- internal leveldb error while iterating for txids
- invalid txIDKey - zero-length slice
- invalid txIDKey {%x} - unexpected prefix
- invalid txIDKey {%x}, fewer bytes present
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/3eea289bc95eb795.
Report an issue: GitHub.