{"record":{"id":"19d707ec04cfd2af","repo":"hyperledger/fabric","slug":"collection-name-s-found-duplicate-collection","errorCode":null,"errorMessage":"collection-name: %s -- found duplicate collection configuration","messagePattern":"collection-name: (.+?) -- found duplicate collection configuration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":222,"sourceCode":"\t// Process each collection config from a set of collection configs\n\tfor _, newCollectionConfig := range newCollectionConfigs {\n\n\t\tnewCollection := newCollectionConfig.GetStaticCollectionConfig()\n\t\tif newCollection == nil {\n\t\t\treturn errors.New(\"unknown collection configuration type\")\n\t\t}\n\n\t\t// Ensure that there are no duplicate collection names\n\t\tcollectionName := newCollection.GetName()\n\n\t\tif err := validateCollectionName(collectionName); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif _, ok := newCollectionsMap[collectionName]; !ok {\n\t\t\tnewCollectionsMap[collectionName] = true\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"collection-name: %s -- found duplicate collection configuration\", collectionName)\n\t\t}\n\n\t\t// Validate gossip related parameters present in the collection config\n\t\tmaximumPeerCount := newCollection.GetMaximumPeerCount()\n\t\trequiredPeerCount := newCollection.GetRequiredPeerCount()\n\t\tif maximumPeerCount < requiredPeerCount {\n\t\t\treturn fmt.Errorf(\"collection-name: %s -- maximum peer count (%d) cannot be less than the required peer count (%d)\",\n\t\t\t\tcollectionName, maximumPeerCount, requiredPeerCount)\n\t\t}\n\t\tif requiredPeerCount < 0 {\n\t\t\treturn fmt.Errorf(\"collection-name: %s -- requiredPeerCount (%d) cannot be less than zero\",\n\t\t\t\tcollectionName, requiredPeerCount)\n\t\t}\n\n\t\t// make sure that the signature policy is meaningful (only consists of ORs)\n\t\terr := validateSpOrConcat(newCollection.MemberOrgsPolicy.GetSignaturePolicy().Rule)\n\t\tif err != nil {\n\t\t\treturn errors.WithMessagef(err, \"collection-name: %s -- error in member org policy\", collectionName)","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L204-L240","documentation":"During a collection configuration upgrade, two or more collection configs in the new package share the same collection name. Collection names must be unique within a chaincode's config, so the upgrade is rejected with the offending name in the message.","triggerScenarios":"Submitting an upgrade whose CollectionConfigPackage lists the same collection name twice (validateRWSetAndCollection -> validateNewCollectionConfigs detects the duplicate in newCollectionsMap).","commonSituations":"Copy-paste errors in collections_config.json; merging collection definitions from multiple files without dedup; automated tooling appending a collection that already exists in the config.","solutions":["Deduplicate collection names in the collections config file before issuing the chaincode upgrade","If you intended to modify an existing collection, keep one entry with the updated parameters instead of adding a second entry with the same name","Validate the JSON with a quick script (e.g. jq checking for duplicate .name values) before peer chaincode upgrade"],"exampleFix":"// before\n[{\"name\":\"col1\",...},{\"name\":\"col1\",...}]\n// after\n[{\"name\":\"col1\",...},{\"name\":\"col2\",...}]","handlingStrategy":"validation","validationCode":"names := map[string]bool{}\nfor _, cfg := range collectionConfigPackage.Config {\n    sc := cfg.GetStaticCollectionConfig()\n    if sc != nil {\n        if names[sc.GetName()] {\n            return fmt.Errorf(\"duplicate collection name: %s\", sc.GetName())\n        }\n        names[sc.GetName()] = true\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run a duplicate-name lint on collections_config.json before upgrades","Merge collection definitions from a single source of truth","Keep a per-chaincode registry of existing collection names to avoid re-adding"],"tags":["go","collections","duplicate","validation"],"backgroundTag":"duplicate-collection-name","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"}