hyperledger/fabric · error
no collection config for chaincode %#v
Error message
no collection config for chaincode %#v
What it means
AssemblePvtRWSet could not find or retrieve a collection configuration package for a chaincode namespace present in the transaction's private read-write set. If not supplied in the input map, it queries AllCollectionsConfigPkg; when that returns nil the chaincode has no collection config defined, so assembly of the private data with collection configs cannot proceed.
Source
Thrown at core/endorser/pvtrwset_assembler.go:67
privData *rwset.TxPvtReadWriteSet,
txsim ledger.SimpleQueryExecutor,
deployedCCInfoProvider ledger.DeployedChaincodeInfoProvider) (
*transientstore.TxPvtReadWriteSetWithConfigInfo, error,
) {
txPvtRwSetWithConfig := &transientstore.TxPvtReadWriteSetWithConfigInfo{
PvtRwset: privData,
CollectionConfigs: make(map[string]*peer.CollectionConfigPackage),
}
for _, pvtRwset := range privData.NsPvtRwset {
namespace := pvtRwset.Namespace
if _, found := txPvtRwSetWithConfig.CollectionConfigs[namespace]; !found {
colCP, err := deployedCCInfoProvider.AllCollectionsConfigPkg(channelName, namespace, txsim)
if err != nil {
return nil, errors.WithMessagef(err, "error while retrieving collection config for chaincode %#v", namespace)
}
if colCP == nil {
return nil, errors.New(fmt.Sprintf("no collection config for chaincode %#v", namespace))
}
txPvtRwSetWithConfig.CollectionConfigs[namespace] = colCP
}
}
trimCollectionConfigs(txPvtRwSetWithConfig)
return txPvtRwSetWithConfig, nil
}
func trimCollectionConfigs(pvtData *transientstore.TxPvtReadWriteSetWithConfigInfo) {
flags := make(map[string]map[string]struct{})
for _, pvtRWset := range pvtData.PvtRwset.NsPvtRwset {
namespace := pvtRWset.Namespace
for _, col := range pvtRWset.CollectionPvtRwset {
if _, found := flags[namespace]; !found {
flags[namespace] = make(map[string]struct{})
}
flags[namespace][col.CollectionName] = struct{}{}
}View on GitHub (pinned to 2736b63f8f)
Solutions
- Approve/commit the chaincode definition including --collections-config with the required collections before invoking
- Ensure the client's collections-config.json matches the collections defined in the chaincode definition (collection names are case-sensitive)
- If collections were removed in an upgrade, stop sending private data for those namespaces or re-add the collections
- Check peer logs for the preceding 'error while retrieving collection config' message if err is wrapped (that would indicate a different root cause)
Example fix
# before: invoke without collections in definition peer chaincode approveformyorg -C mychannel -n mycc -v 2.0 # after peer chaincode approveformyorg -C mychannel -n mycc -v 2.0 --collections-config collections-config.json
Defensive patterns
Strategy: validation
Validate before calling
const ccd = await network.getContract('mycc').getChaincodeDefinition?.() // or query approved definition
if (!collectionsConfig || collectionsConfig.length === 0) {
throw new Error('chaincode has no collection config; cannot submit private data');
} Type guard
function hasCollections(def) { return Array.isArray(def?.collections_config) && def.collections_config.length > 0; } Try / catch
try {
await contract.submitTransaction('putPrivate', ...);
} catch (e) {
if (e.message.includes('no collection config for chaincode')) {
throw new Error('approve/commit the chaincode with --collections-config first', { cause: e });
}
throw e;
} Prevention
- Always pass --collections-config when approving/committing chaincode that uses private data
- Keep the client-side collections-config.json identical to the approved definition
- Re-verify collection names after chaincode upgrades (names are case-sensitive)
- Stop sending transient data for collections removed in upgrades
When it happens
Trigger: AssemblePvtRWSet called (during endorsement of a private-data transaction) where txPvtRwSetWithConfig.CollectionConfigs lacks the namespace and deployedCCInfoProvider.AllCollectionsConfigPkg returns nil — i.e. the chaincode has no private data collections defined in its definition.
Common situations: Chaincode invoked with transient data / --collections-file mismatch: client uses a collections-config.json whose collection isn't in the chaincode's approved definition; chaincode upgraded and collections removed while clients still send private data; invoking private data functions on a chaincode never approved with collection config.
Related errors
- tx creator does not have read access permission on privateda
- tx creator does not have write access permission on privated
- collection configuration is empty
- Private data is forbidden to be used in instantiate
- unknown collection configuration type
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/cf2298db7dd5d0f9.
Report an issue: GitHub.