{"record":{"id":"75e4150376f1f4c3","repo":"hyperledger/fabric","slug":"memberorgspolicy-of-s-is-nil","errorCode":null,"errorMessage":"MemberOrgsPolicy of %s is nil","messagePattern":"MemberOrgsPolicy of (.+?) is nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/endorsement/collection.go","lineNumber":29,"sourceCode":"\t\"github.com/hyperledger/fabric/common/policies\"\n\t\"github.com/hyperledger/fabric/gossip/api\"\n\t\"github.com/pkg/errors\"\n)\n\nfunc principalsFromCollectionConfig(ccp *peer.CollectionConfigPackage) (principalSetsByCollectionName, error) {\n\tprincipalSetsByCollections := make(principalSetsByCollectionName)\n\tif ccp == nil {\n\t\treturn principalSetsByCollections, nil\n\t}\n\tfor _, colConfig := range ccp.Config {\n\t\tstaticCol := colConfig.GetStaticCollectionConfig()\n\t\tif staticCol == nil {\n\t\t\t// Right now we only support static collections, so if we got something else\n\t\t\t// we should refuse to process further\n\t\t\treturn nil, errors.Errorf(\"expected a static collection but got %v instead\", colConfig)\n\t\t}\n\t\tif staticCol.MemberOrgsPolicy == nil {\n\t\t\treturn nil, errors.Errorf(\"MemberOrgsPolicy of %s is nil\", staticCol.Name)\n\t\t}\n\t\tpol := staticCol.MemberOrgsPolicy.GetSignaturePolicy()\n\t\tif pol == nil {\n\t\t\treturn nil, errors.Errorf(\"policy of %s is nil\", staticCol.Name)\n\t\t}\n\t\tvar principals policies.PrincipalSet\n\t\t// We now extract all principals from the policy\n\t\tfor _, principal := range pol.Identities {\n\t\t\tprincipals = append(principals, principal)\n\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","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/endorsement/collection.go#L11-L47","documentation":"To derive which organizations can endorse for a collection, discovery reads the collection's MemberOrgsPolicy. If a static collection in the chaincode's collection config has a nil MemberOrgsPolicy, discovery cannot compute the principal set and fails with this error naming the collection.","triggerScenarios":"A deployed collection definition with MemberOrgsPolicy unset (empty/incorrectly serialized collection config) reaching principalsFromCollectionConfig via loadMetadataAndFilters during a PeersForEndorsement request.","commonSituations":"Programmatically constructed collection JSON missing the member_orgs_policy field; config corrupted through tooling that dropped the policy; mismatches between collection config format versions.","solutions":["Redeploy the collection config ensuring every collection specifies a member orgs policy (e.g. OR('Org1MSP.peer','Org2MSP.peer'))","Validate the collection JSON before approval (verify memberOrgsPolicy present)","Re-approve/re-commit the chaincode definition with a corrected collections file"],"exampleFix":"// before collection JSON\n{\"name\":\"coll1\",\"requiredPeerCount\":1,\"maxPeerCount\":2}\n\n// after\n{\"name\":\"coll1\",\"memberOrgsPolicy\":{\"signaturePolicy\":{\"identities\":[{\"role\":{\"name\":\"peer\",\"mspId\":\"Org1MSP\"}}]}},\"requiredPeerCount\":1,\"maxPeerCount\":2}","handlingStrategy":"validation","validationCode":"for _, col := range collConfig.Config {\n    sc := col.GetStaticCollectionConfig()\n    if sc != nil && sc.MemberOrgsPolicy == nil {\n        return fmt.Errorf(\"collection %s missing memberOrgsPolicy\", sc.Name)\n    }\n}","typeGuard":"func hasMemberOrgsPolicy(sc *pb.StaticCollectionConfig) bool {\n    return sc != nil && sc.GetMemberOrgsPolicy() != nil\n}","tryCatchPattern":"_, err := coll.PrincipalsFromCollectionConfig(ccp)\nif err != nil {\n    if strings.Contains(err.Error(), \"MemberOrgsPolicy\") {\n        col := strings.Split(err.Error(), \"MemberOrgsPolicy of \")[1]\n        return nil, fmt.Errorf(\"fix memberOrgsPolicy for collection %s and re-approve\", strings.TrimSuffix(col, \" is nil\"))\n    }\n    return nil, err\n}","preventionTips":["Validate collection JSON includes memberOrgsPolicy before chaincode approval","Use peer lifecycle chaincode checkcommitreadiness/getcollectionsconfig to inspect deployed config","Never hand-edit deployed collection definitions without the signature policy block"],"tags":["discovery","collections","policy"],"backgroundTag":"nil-collection-policy","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"}