hyperledger/fabric · error

collection %s doesn't exist in collection config for chainco

Error message

collection %s doesn't exist in collection config for chaincode %s

What it means

When building an identity filter for a collection-aware endorsement request, discovery maps each requested collection name to the principal set computed from the chaincode's collection config. If a requested collection name is not found in that config, discovery cannot determine which peers' identities satisfy it, so toIdentityFilter returns this error.

Source

Thrown at discovery/endorsement/collection.go:57

		}
		principalSetsByCollections[staticCol.Name] = principals
	}
	return principalSetsByCollections, nil
}

type principalSetsByCollectionName map[string]policies.PrincipalSet

// toIdentityFilter converts this principalSetsByCollectionName mapping to a filter
// which accepts or rejects identities of peers.
func (psbc principalSetsByCollectionName) toIdentityFilter(channel string, evaluator principalEvaluator, cc *peer.ChaincodeCall) (identityFilter, error) {
	var principalSets policies.PrincipalSets
	for _, col := range cc.CollectionNames {
		// Each collection we're interested in should exist in the principalSetsByCollectionName mapping.
		// Otherwise, we have no way of computing a filter because we can't locate the principals the peer identities
		// need to satisfy.
		principalSet, exists := psbc[col]
		if !exists {
			return nil, errors.Errorf("collection %s doesn't exist in collection config for chaincode %s", col, cc.Name)
		}
		principalSets = append(principalSets, principalSet)
	}
	return filterForPrincipalSets(channel, evaluator, principalSets), nil
}

// filterForPrincipalSets creates a filter of peer identities out of the given PrincipalSets
func filterForPrincipalSets(channel string, evaluator principalEvaluator, sets policies.PrincipalSets) identityFilter {
	return func(identity api.PeerIdentityType) bool {
		// Iterate over all principal sets and ensure each principal set
		// authorizes the identity.
		for _, principalSet := range sets {
			if !isIdentityAuthorizedByPrincipalSet(channel, evaluator, principalSet, identity) {
				return false
			}
		}
		return true
	}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Correct the collection name in the request to one defined in the chaincode's collection config
  2. Refresh the collection list (query installed collection config via peer) and update the client
  3. Redeploy the missing collection via a chaincode definition update if it should exist

Example fix

// before
req = req.AddPeersForEndorsement(discovery.CollectionCriteria{
    Name: "mycc", CollectionsFilter: []string{"colA", "colB"}}) // colB doesn't exist

// after
req = req.AddPeersForEndorsement(discovery.CollectionCriteria{
    Name: "mycc", CollectionsFilter: []string{"colA"}})
Defensive patterns

Strategy: validation

Validate before calling

const defined = await getCollectionNames(chaincodeName); // via peer query
const invalid = collectionsFilter.filter(c => !defined.includes(c));
if (invalid.length > 0) {
  throw new Error(`collections not defined for ${chaincodeName}: ${invalid.join(',')}`);
}

Try / catch

desc, err := client.PeersForEndorsement(req)
if err != nil {
    if strings.Contains(err.Error(), "doesn't exist in collection config") {
        // re-fetch collection config and correct the filter before retrying
        return nil, fmt.Errorf("stale collection filter: %w", err)
    }
    return nil, err
}

Prevention

When it happens

Trigger: PeersForEndorsement request with CollectionsFilter listing a collection name that is not defined in the chaincode's current collection configuration on the channel.

Common situations: Client requests a collection that was removed or renamed in a chaincode upgrade; typo in the collection name in the discovery request; client cached an old collection list from before an upgrade.

Related errors


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