{"record":{"id":"3eea289bc95eb795","repo":"hyperledger/fabric","slug":"no-such-blocknumber-transactionnumber-d-d-in","errorCode":null,"errorMessage":"no such blockNumber, transactionNumber <%d, %d> in index","messagePattern":"no such blockNumber, transactionNumber <(.+?), (.+?)> in index","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/ledger/blkstorage/blockindex.go","lineNumber":282,"sourceCode":"\t\treturn nil, 0, errors.Wrapf(err, \"unexpected error while unmarshalling bytes [%#v] into TxIDIndexValProto\", valBytes)\n\t}\n\tblockNum, err := retrieveBlockNum(itr.Key(), len(rangeScan.startKey))\n\tif err != nil {\n\t\treturn nil, 0, errors.WithMessage(err, \"error while decoding block number from txID index key\")\n\t}\n\treturn val, blockNum, nil\n}\n\nfunc (index *blockIndex) getTXLocByBlockNumTranNum(blockNum uint64, tranNum uint64) (*fileLocPointer, error) {\n\tif !index.isAttributeIndexed(IndexableAttrBlockNumTranNum) {\n\t\treturn nil, errors.New(\"<blockNumber, transactionNumber> tuple not maintained in index\")\n\t}\n\tb, err := index.db.Get(constructBlockNumTranNumKey(blockNum, tranNum))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif b == nil {\n\t\treturn nil, errors.Errorf(\"no such blockNumber, transactionNumber <%d, %d> in index\", blockNum, tranNum)\n\t}\n\ttxFLP := &fileLocPointer{}\n\tif err := txFLP.unmarshal(b); err != nil {\n\t\treturn nil, err\n\t}\n\treturn txFLP, nil\n}\n\nfunc (index *blockIndex) exportUniqueTxIDs(dir string, newHashFunc snapshot.NewHashFunc) (map[string][]byte, error) {\n\tif !index.isAttributeIndexed(IndexableAttrTxID) {\n\t\treturn nil, errors.New(\"transaction IDs not maintained in index\")\n\t}\n\n\tdbItr, err := index.db.GetIterator([]byte{txIDIdxKeyPrefix}, []byte{txIDIdxKeyPrefix + 1})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer dbItr.Release()","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/ledger/blkstorage/blockindex.go#L264-L300","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before: blind lookup\nloc, err := blkStorage.RetrieveTransactionByBlockNumTranNum(ledgerID, blockNum, txNum)\n// after: bounds-check first\nif blockNum >= bcInfo.Height {\n    return fmt.Errorf(\"block %d not committed (height=%d)\", blockNum, bcInfo.Height)\n}\nloc, err := blkStorage.RetrieveTransactionByBlockNumTranNum(ledgerID, blockNum, txNum)","handlingStrategy":"validation","validationCode":"bcInfo, err := ledger.GetBlockchainInfo()\nif err != nil { return err }\nif blockNum >= bcInfo.Height {\n    return fmt.Errorf(\"block %d not present: ledger height is %d\", blockNum, bcInfo.Height)\n}\n// additionally ensure tranNum < number of txs in block before lookup","typeGuard":null,"tryCatchPattern":"loc, err := retrieveTransactionByBlockNumTranNum(blockNum, tranNum)\nif err != nil && strings.Contains(err.Error(), \"no such blockNumber, transactionNumber\") {\n    // treat as not-found, not as a system failure\n    return nil, ErrTransactionNotFound\n}\nif err != nil { return err }","preventionTips":["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."],"tags":["leveldb","ledger","blockstorage","indexing"],"backgroundTag":"record-not-found-in-index","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"}