{"record":{"id":"cf2298db7dd5d0f9","repo":"hyperledger/fabric","slug":"no-collection-config-for-chaincode-v","errorCode":null,"errorMessage":"no collection config for chaincode %#v","messagePattern":"no collection config for chaincode %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/endorser/pvtrwset_assembler.go","lineNumber":67,"sourceCode":"\tprivData *rwset.TxPvtReadWriteSet,\n\ttxsim ledger.SimpleQueryExecutor,\n\tdeployedCCInfoProvider ledger.DeployedChaincodeInfoProvider) (\n\t*transientstore.TxPvtReadWriteSetWithConfigInfo, error,\n) {\n\ttxPvtRwSetWithConfig := &transientstore.TxPvtReadWriteSetWithConfigInfo{\n\t\tPvtRwset:          privData,\n\t\tCollectionConfigs: make(map[string]*peer.CollectionConfigPackage),\n\t}\n\n\tfor _, pvtRwset := range privData.NsPvtRwset {\n\t\tnamespace := pvtRwset.Namespace\n\t\tif _, found := txPvtRwSetWithConfig.CollectionConfigs[namespace]; !found {\n\t\t\tcolCP, err := deployedCCInfoProvider.AllCollectionsConfigPkg(channelName, namespace, txsim)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.WithMessagef(err, \"error while retrieving collection config for chaincode %#v\", namespace)\n\t\t\t}\n\t\t\tif colCP == nil {\n\t\t\t\treturn nil, errors.New(fmt.Sprintf(\"no collection config for chaincode %#v\", namespace))\n\t\t\t}\n\t\t\ttxPvtRwSetWithConfig.CollectionConfigs[namespace] = colCP\n\t\t}\n\t}\n\ttrimCollectionConfigs(txPvtRwSetWithConfig)\n\treturn txPvtRwSetWithConfig, nil\n}\n\nfunc trimCollectionConfigs(pvtData *transientstore.TxPvtReadWriteSetWithConfigInfo) {\n\tflags := make(map[string]map[string]struct{})\n\tfor _, pvtRWset := range pvtData.PvtRwset.NsPvtRwset {\n\t\tnamespace := pvtRWset.Namespace\n\t\tfor _, col := range pvtRWset.CollectionPvtRwset {\n\t\t\tif _, found := flags[namespace]; !found {\n\t\t\t\tflags[namespace] = make(map[string]struct{})\n\t\t\t}\n\t\t\tflags[namespace][col.CollectionName] = struct{}{}\n\t\t}","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/endorser/pvtrwset_assembler.go#L49-L85","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"# before: invoke without collections in definition\npeer chaincode approveformyorg -C mychannel -n mycc -v 2.0\n# after\npeer chaincode approveformyorg -C mychannel -n mycc -v 2.0 --collections-config collections-config.json","handlingStrategy":"validation","validationCode":"const ccd = await network.getContract('mycc').getChaincodeDefinition?.() // or query approved definition\nif (!collectionsConfig || collectionsConfig.length === 0) {\n  throw new Error('chaincode has no collection config; cannot submit private data');\n}","typeGuard":"function hasCollections(def) { return Array.isArray(def?.collections_config) && def.collections_config.length > 0; }","tryCatchPattern":"try {\n  await contract.submitTransaction('putPrivate', ...);\n} catch (e) {\n  if (e.message.includes('no collection config for chaincode')) {\n    throw new Error('approve/commit the chaincode with --collections-config first', { cause: e });\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["hyperledger-fabric","endorser","private-data","collections","chaincode"],"backgroundTag":"missing-collection-config","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}