hyperledger/fabric · error

transaction IDs not maintained in index

Error message

transaction IDs not maintained in index

What it means

Returned by blockIndex.txIDExists when the TXID attribute is not enabled in the ledger's index configuration. It signals a configuration mismatch: the caller asks for tx-ID lookups the index was never built to serve.

Source

Thrown at common/ledger/blkstorage/blockindex.go:224

	}
	blkFLP := &fileLocPointer{}
	if err = blkFLP.unmarshal(v.BlkLocation); err != nil {
		return nil, err
	}
	return blkFLP, nil
}

func (index *blockIndex) getTxValidationCodeByTxID(txID string) (peer.TxValidationCode, uint64, error) {
	v, blkNum, err := index.getTxIDVal(txID)
	if err != nil {
		return peer.TxValidationCode(-1), 0, err
	}
	return peer.TxValidationCode(v.TxValidationCode), blkNum, nil
}

func (index *blockIndex) txIDExists(txID string) (bool, error) {
	if !index.isAttributeIndexed(IndexableAttrTxID) {
		return false, errors.New("transaction IDs not maintained in index")
	}
	rangeScan := constructTxIDRangeScan(txID)
	itr, err := index.db.GetIterator(rangeScan.startKey, rangeScan.stopKey)
	if err != nil {
		return false, errors.WithMessagef(err, "error while trying to check the presence of TXID [%s]", txID)
	}
	defer itr.Release()

	present := itr.Next()
	if err := itr.Error(); err != nil {
		return false, errors.Wrapf(err, "error while trying to check the presence of TXID [%s]", txID)
	}
	return present, nil
}

func (index *blockIndex) getTxIDVal(txID string) (*TxIDIndexValue, uint64, error) {
	if !index.isAttributeIndexed(IndexableAttrTxID) {
		return nil, 0, errors.New("transaction IDs not maintained in index")

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Enable txid in index attrs and rebuild the index
  2. Use default indexing config
  3. Maintain txid bookkeeping outside the ledger if indexing stays disabled

Example fix

// before
attrs: []blkstorage.IndexableAttr{blkstorage.IndexableAttrBlockNum}
// after
attrs: append(attrs, blkstorage.IndexableAttrTxID)
Defensive patterns

Strategy: validation

Validate before calling

func ensureTxIDIndexed(cfg *blkstorage.IndexConfig) error {
    for _, a := range cfg.Attrs {
        if a == blkstorage.IndexableAttrTxID { return nil }
    }
    return errors.New("txid indexing disabled: TxIDExists unavailable")
}

Type guard

func txIDIndexed(attrs []blkstorage.IndexableAttr) bool {
    for _, a := range attrs { if a == blkstorage.IndexableAttrTxID { return true } }
    return false
}

Try / catch

exists, err := store.TxIDExists(txid)
if err != nil {
    if strings.Contains(err.Error(), "transaction IDs not maintained") {
        return fallbackLocalDupCheck(txid) // client-side/submitted-tx registry
    }
    return err
}

Prevention

When it happens

Trigger: txIDExists invoked against a store whose indexAttrs exclude txid; unsupported-capability error raised immediately.

Common situations: Minimal index configurations, config copied from a txid-less deployment.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/0667ac19fd001467. Report an issue: GitHub.