hyperledger/fabric · error

no collection config was found for collection %s for chainco

Error message

no collection config was found for collection %s for chaincode %s

What it means

A collection config update record was found, but the specific collectionName is not present among the collection configs in that update's CollectionConfig payload. extractCollectionConfig returned nil, so the reconciler cannot map the digest to a collection config.

Source

Thrown at gossip/privdata/reconcile.go:249

}

func (r *Reconciler) getMostRecentCollectionConfig(chaincodeName string, collectionName string, blockNum uint64) (*peer.StaticCollectionConfig, error) {
	configHistoryRetriever, err := r.GetConfigHistoryRetriever()
	if err != nil {
		return nil, errors.Wrap(err, "configHistoryRetriever is not available")
	}

	configInfo, err := configHistoryRetriever.MostRecentCollectionConfigBelow(blockNum, chaincodeName)
	if err != nil {
		return nil, errors.New(fmt.Sprintf("cannot find recent collection config update below block sequence = %d for chaincode %s", blockNum, chaincodeName))
	}
	if configInfo == nil {
		return nil, errors.New(fmt.Sprintf("no collection config update below block sequence = %d for chaincode %s is available", blockNum, chaincodeName))
	}

	collectionConfig := extractCollectionConfig(configInfo.CollectionConfig, collectionName)
	if collectionConfig == nil {
		return nil, errors.New(fmt.Sprintf("no collection config was found for collection %s for chaincode %s", collectionName, chaincodeName))
	}

	staticCollectionConfig, wasCastingSuccessful := collectionConfig.Payload.(*peer.CollectionConfig_StaticCollectionConfig)
	if !wasCastingSuccessful {
		return nil, errors.New(fmt.Sprintf("expected collection config of type CollectionConfig_StaticCollectionConfig for collection %s for chaincode %s, while got different config type...", collectionName, chaincodeName))
	}
	return staticCollectionConfig.StaticCollectionConfig, nil
}

func (r *Reconciler) preparePvtDataToCommit(elements []*protosgossip.PvtDataElement) []*ledger.ReconciledPvtdata {
	rwSetByBlockByKeys := r.groupRwsetByBlock(elements)

	// populate the private RWSets passed to the ledger
	var pvtDataToCommit []*ledger.ReconciledPvtdata

	for blockNum, rwSetKeys := range rwSetByBlockByKeys {
		blockPvtData := &ledger.ReconciledPvtdata{
			BlockNum:  blockNum,

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Check the collection name against the chaincode's collections_config.json for exact spelling.
  2. Confirm the collection existed at the block being reconciled; if it was added later, that old data cannot be reconciled via this config.
  3. Redeploy/upgrade the chaincode with the correct collection definition.
  4. Review chaincode lifecycle history to see when the collection was introduced.

Example fix

// before
peer chaincode query collections-config ...
// collection 'priv' not listed
// after: fix collections_config.json and upgrade chaincode
{
  "name": "priv",
  "policy": "OR('Org1MSP.member','Org2MSP.member')",
  "requiredPeerCount": 1,
  "maxPeerCount": 2
}
Defensive patterns

Strategy: validation

Validate before calling

// cross-check collection names against the deployed collections config
collections, err := loadCollectionsConfig("collections_config.json")
if err != nil || !contains(collections, collectionName) {
    log.Warningf("collection %s not defined for chaincode %s", collectionName, chaincodeName)
}

Try / catch

cfg, err := r.getMostRecentCollectionConfig(cc, coll, blockNum)
if err != nil {
    if strings.Contains(err.Error(), "no collection config was found for collection") {
        log.Warningf("unknown collection %s for %s; skipping dig", coll, cc)
        return
    }
    return err
}

Prevention

When it happens

Trigger: getMostRecentCollectionConfig (via getDig2CollectionConfig) when the most recent config update below blockNum exists but does not contain an entry for collectionName of chaincodeName.

Common situations: Typo in the collection name in queries or collection JSON; collection was added in a later config update than the one found below blockNum; reconciling very old missing data whose collection was defined later; chaincode upgraded with a renamed collection.

Related errors


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