{"record":{"id":"5d351af57adca03f","repo":"hyperledger/fabric","slug":"collection-s-doesn-t-exist-in-collection-config-f","errorCode":null,"errorMessage":"collection %s doesn't exist in collection config for chaincode %s","messagePattern":"collection (.+?) doesn't exist in collection config for chaincode (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/endorsement/collection.go","lineNumber":57,"sourceCode":"\t\t}\n\t\tprincipalSetsByCollections[staticCol.Name] = principals\n\t}\n\treturn principalSetsByCollections, nil\n}\n\ntype principalSetsByCollectionName map[string]policies.PrincipalSet\n\n// toIdentityFilter converts this principalSetsByCollectionName mapping to a filter\n// which accepts or rejects identities of peers.\nfunc (psbc principalSetsByCollectionName) toIdentityFilter(channel string, evaluator principalEvaluator, cc *peer.ChaincodeCall) (identityFilter, error) {\n\tvar principalSets policies.PrincipalSets\n\tfor _, col := range cc.CollectionNames {\n\t\t// Each collection we're interested in should exist in the principalSetsByCollectionName mapping.\n\t\t// Otherwise, we have no way of computing a filter because we can't locate the principals the peer identities\n\t\t// need to satisfy.\n\t\tprincipalSet, exists := psbc[col]\n\t\tif !exists {\n\t\t\treturn nil, errors.Errorf(\"collection %s doesn't exist in collection config for chaincode %s\", col, cc.Name)\n\t\t}\n\t\tprincipalSets = append(principalSets, principalSet)\n\t}\n\treturn filterForPrincipalSets(channel, evaluator, principalSets), nil\n}\n\n// filterForPrincipalSets creates a filter of peer identities out of the given PrincipalSets\nfunc filterForPrincipalSets(channel string, evaluator principalEvaluator, sets policies.PrincipalSets) identityFilter {\n\treturn func(identity api.PeerIdentityType) bool {\n\t\t// Iterate over all principal sets and ensure each principal set\n\t\t// authorizes the identity.\n\t\tfor _, principalSet := range sets {\n\t\t\tif !isIdentityAuthorizedByPrincipalSet(channel, evaluator, principalSet, identity) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/endorsement/collection.go#L39-L75","documentation":"When building an identity filter for a collection-aware endorsement request, discovery maps each requested collection name to the principal set computed from the chaincode's collection config. If a requested collection name is not found in that config, discovery cannot determine which peers' identities satisfy it, so toIdentityFilter returns this error.","triggerScenarios":"PeersForEndorsement request with CollectionsFilter listing a collection name that is not defined in the chaincode's current collection configuration on the channel.","commonSituations":"Client requests a collection that was removed or renamed in a chaincode upgrade; typo in the collection name in the discovery request; client cached an old collection list from before an upgrade.","solutions":["Correct the collection name in the request to one defined in the chaincode's collection config","Refresh the collection list (query installed collection config via peer) and update the client","Redeploy the missing collection via a chaincode definition update if it should exist"],"exampleFix":"// before\nreq = req.AddPeersForEndorsement(discovery.CollectionCriteria{\n    Name: \"mycc\", CollectionsFilter: []string{\"colA\", \"colB\"}}) // colB doesn't exist\n\n// after\nreq = req.AddPeersForEndorsement(discovery.CollectionCriteria{\n    Name: \"mycc\", CollectionsFilter: []string{\"colA\"}})","handlingStrategy":"validation","validationCode":"const defined = await getCollectionNames(chaincodeName); // via peer query\nconst invalid = collectionsFilter.filter(c => !defined.includes(c));\nif (invalid.length > 0) {\n  throw new Error(`collections not defined for ${chaincodeName}: ${invalid.join(',')}`);\n}","typeGuard":null,"tryCatchPattern":"desc, err := client.PeersForEndorsement(req)\nif err != nil {\n    if strings.Contains(err.Error(), \"doesn't exist in collection config\") {\n        // re-fetch collection config and correct the filter before retrying\n        return nil, fmt.Errorf(\"stale collection filter: %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Fetch the live collection config before building CollectionCriteria","Update cached collection names after every chaincode upgrade","Validate collection names against the committed definition in tests"],"tags":["discovery","collections","endorsement"],"backgroundTag":"collection-not-found","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"}