hyperledger/fabric · error

no such collection '%s'

Error message

no such collection '%s'

What it means

CollectionValidationInfo returns this when the requested collectionName is not found among the chaincode's defined static collections and it is not an implicit collection name. It means the transaction or query referenced a private data collection that the committed chaincode definition does not declare.

Source

Thrown at core/chaincode/lifecycle/deployedcc_infoprovider.go:376

	isImplicitCollection, mspID := implicitcollection.MspIDIfImplicitCollection(collectionName)
	if isImplicitCollection {
		return vc.ImplicitCollectionEndorsementPolicyAsBytes(channelID, mspID)
	}

	if definedChaincode.Collections != nil {
		for _, conf := range definedChaincode.Collections.Config {
			staticCollConfig := conf.GetStaticCollectionConfig()
			if staticCollConfig != nil && staticCollConfig.Name == collectionName {
				if staticCollConfig.EndorsementPolicy != nil {
					return protoutil.MarshalOrPanic(staticCollConfig.EndorsementPolicy), nil, nil
				}
				// default to chaincode endorsement policy
				return definedChaincode.ValidationInfo.ValidationParameter, nil, nil
			}
		}
	}

	return nil, nil, errors.Errorf("no such collection '%s'", collectionName)
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Compare the collection name used at runtime against the committed collections.json (peer lifecycle chaincode queryinstalled/committed and collections-config).
  2. Fix the collection name in the chaincode or client query to match the committed definition exactly.
  3. If a new collection is needed, package updated collections config and commit a new chaincode definition sequence on the channel.
  4. Ensure all orgs have approved the definition containing the new collection before invoking.

Example fix

// before
handle.GetPrivateData("_invisible_col", key)
// after (name must match collections.json exactly)
handle.GetPrivateData("collectionOne", key)
Defensive patterns

Strategy: validation

Validate before calling

// Go: confirm the collection name exists in the committed definition before use
committed, _ := client.Lifecycle().QueryChaincodeDefinition(name, channel)
known := map[string]bool{"collectionOne": true, "_implicit_org_Org1MSP": true}
if !known[collectionName] {
  return fmt.Errorf("collection %s not in committed definition", collectionName)
}

Try / catch

err := handle.GetPrivateData(coll, key)
if err != nil && strings.Contains(err.Error(), "no such collection") {
  // correct name or commit new definition including the collection
}

Prevention

When it happens

Trigger: Endorsement/validation requests CollectionValidationInfo(channelID, chaincodeName, collectionName) with a name that is neither in the chaincode's collections config nor of the form _implicit_org_<MSPID>.

Common situations: Typo in collection name in the chaincode (getStateByRange/private data APIs) or in collections.json; client queries a collection defined in a newer version of chaincode while the peer still runs the old definition; collection name case mismatch.

Related errors


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