{"record":{"id":"5d6b9f62ea108d7d","repo":"hyperledger/fabric","slug":"the-proposed-collection-config-does-not-contain-pr","errorCode":null,"errorMessage":"the proposed collection config does not contain previously defined collections","messagePattern":"the proposed collection config does not contain previously defined collections","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/scc.go","lineNumber":929,"sourceCode":"\tfor _, rule := range sp.GetNOutOf().Rules {\n\t\terr := validateSpOrConcat(rule)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateCollConfigsAgainstCommittedDef(\n\tproposedCollConfs []*pb.StaticCollectionConfig,\n\tcommittedCollConfPkg *pb.CollectionConfigPackage,\n) error {\n\tif committedCollConfPkg == nil || len(committedCollConfPkg.Config) == 0 {\n\t\treturn nil\n\t}\n\n\tif len(proposedCollConfs) == 0 {\n\t\treturn errors.Errorf(\"the proposed collection config does not contain previously defined collections\")\n\t}\n\n\tproposedCollsMap := map[string]*pb.StaticCollectionConfig{}\n\tfor _, c := range proposedCollConfs {\n\t\tproposedCollsMap[c.Name] = c\n\t}\n\n\t// In the new collection config package, ensure that there is one entry per old collection. Any\n\t// number of new collections are allowed.\n\tfor _, committedCollConfig := range committedCollConfPkg.Config {\n\t\tcommittedColl := committedCollConfig.GetStaticCollectionConfig()\n\t\t// It cannot be nil\n\t\tif committedColl == nil {\n\t\t\treturn errors.Errorf(\"unknown collection configuration type\")\n\t\t}\n\n\t\tnewCollection, ok := proposedCollsMap[committedColl.Name]\n\t\tif !ok {","sourceCodeStart":911,"sourceCodeEnd":947,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/scc.go#L911-L947","documentation":"When a chaincode already has committed collections, any upgrade must re-include every existing collection. This error is thrown when the committed definition has collection data but the proposed definition supplies none, because fabric would interpret the missing entries as dropping existing collections, which is forbidden.","triggerScenarios":"Upgrading a chaincode definition (approveformyorg / commit / _lifecycle chaincode) that previously had collections configured, but omitting --collections-config or passing an empty collection config.","commonSituations":"Upgrade performed with CLI that omits the collections-config flag used in the original deployment; tooling that rebuilds definitions from scratch and forgets prior collection packages.","solutions":["Pass the full collection config (including all previously defined collections) on the upgrade via --collections-config.","Read the committed definition's collection config (via QueryApprovedChaincodeDefinition or committed data) and include it in the new definition.","Do not omit the collections-config flag once collections exist for the chaincode."],"exampleFix":"// before: upgrade without collections\npeer chaincode invoke -C mychannel -n _lifecycle -c '{\"Args\":[\"ApproveChaincodeDefinitionForMyOrg\",...,\"{}\"]}'\n// after: include existing + new collections\npeer chaincode invoke ... -c '{\"Args\":[\"ApproveChaincodeDefinitionForMyOrg\",...,\"{\\\"collection1\\\":{...}}\"]}'","handlingStrategy":"validation","validationCode":"committed, _ := qc.QueryChaincodeDefinitionResult(ccName, channelID)\nif committed.Collections != nil && len(proposedCollections) == 0 {\n  return fmt.Errorf(\"chaincode %s has committed collections; upgrade must include them\", ccName)\n}","typeGuard":"func hasCommittedCollections(def *lifecycle.QueryChaincodeDefinitionResult) bool {\n  return def != nil && def.Collections != nil && len(def.Collections.Config) > 0\n}","tryCatchPattern":"if err := commit(...); err != nil {\n  if strings.Contains(err.Error(), \"does not contain previously defined collections\") {\n    // re-run with full --collections-config including existing collections\n  }\n  return err\n}","preventionTips":["Always pass --collections-config on upgrades of chaincodes that have collections.","Query the committed definition and merge collections into each new proposal.","Automate upgrades to carry forward prior collection packages."],"tags":["fabric","private-data","chaincode-upgrade","collection-config"],"backgroundTag":"missing-collections-in-upgrade","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"}