{"record":{"id":"9e363a98e9193a80","repo":"hyperledger/fabric","slug":"requested-to-disregard-chaincode-s-s-policy-but-k","errorCode":null,"errorMessage":"requested to disregard chaincode %s's policy but key and collection policies are missing, either disable DisregardNamespacePolicy or specify at least one key policy or at least one collection policy","messagePattern":"requested to disregard chaincode (.+?)'s policy but key and collection policies are missing, either disable DisregardNamespacePolicy or specify at least one key policy or at least one collection policy","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/endorsement/endorsement.go","lineNumber":274,"sourceCode":"\tlogger.Debugf(\"No state based policies requested\")\n\n\treturn nil, nil\n}\n\nfunc (ea *endorsementAnalyzer) computePrincipalSets(channelID common.ChannelID, interest *peer.ChaincodeInterest) (policies.PrincipalSets, error) {\n\tsessionLogger := logger.With(\"channel\", string(channelID))\n\tvar inquireablePoliciesForChaincodeAndCollections []policies.InquireablePolicy\n\tfor _, chaincode := range interest.Chaincodes {\n\t\tpolicies := ea.PoliciesByChaincode(string(channelID), chaincode.Name, chaincode.CollectionNames...)\n\t\tif len(policies) == 0 {\n\t\t\tsessionLogger.Debug(\"Policy for chaincode '\", chaincode, \"'doesn't exist\")\n\t\t\treturn nil, errors.New(\"policy not found\")\n\t\t}\n\t\tif chaincode.DisregardNamespacePolicy && len(chaincode.KeyPolicies) == 0 && len(policies) == 1 {\n\t\t\tsessionLogger.Warnf(\"Client requested to disregard chaincode %s's policy, but it did not specify any \"+\n\t\t\t\t\"collection policies or key policies. This is probably a bug in the client side code, as the client should\"+\n\t\t\t\t\"either not specify DisregardNamespacePolicy, or specify at least one key policy or at least one collection policy\", chaincode.Name)\n\t\t\treturn nil, errors.Errorf(\"requested to disregard chaincode %s's policy but key and collection policies are missing, either \"+\n\t\t\t\t\"disable DisregardNamespacePolicy or specify at least one key policy or at least one collection policy\", chaincode.Name)\n\t\t}\n\t\tif chaincode.DisregardNamespacePolicy {\n\t\t\tif len(policies) == 1 {\n\t\t\t\tsessionLogger.Debugf(\"Client requested to disregard the namespace policy for chaincode %s,\"+\n\t\t\t\t\t\" and no collection policies are present\", chaincode.Name)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tsessionLogger.Debugf(\"Client requested to disregard the namespace policy for chaincode %s,\"+\n\t\t\t\t\" however there exist %d collection policies taken into account\", chaincode.Name, len(policies)-1)\n\t\t\tpolicies = policies[1:]\n\t\t}\n\t\tinquireablePoliciesForChaincodeAndCollections = append(inquireablePoliciesForChaincodeAndCollections, policies...)\n\t}\n\n\tvar cpss []inquire.ComparablePrincipalSets\n\n\tfor _, policy := range inquireablePoliciesForChaincodeAndCollections {","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/endorsement/endorsement.go#L256-L292","documentation":"Thrown by computePrincipalSets when the client sets DisregardNamespacePolicy=true on a chaincode but provides no KeyPolicies and the chaincode has only its single namespace policy (no collection policies). The service would then have no policy at all to compute principal sets from, so it rejects the request and warns that this is likely a client-side bug.","triggerScenarios":"A ChaincodeInterest_Chaincode with DisregardNamespacePolicy=true, len(KeyPolicies)==0, and exactly one policy resolved for the chaincode (no collection policies) — e.g. a plain chaincode query with no collections and no key-level policies while asking to skip the namespace policy.","commonSituations":"SDK code that always sets DisregardNamespacePolicy for 'private data' style calls but forgot to attach collection names or key policies; misconfigured ChaincodeInterest builders.","solutions":["Set DisregardNamespacePolicy=false (leave it default) for plain chaincode endorsement requests","Or supply at least one KeyPolicy (state-based endorsement policy) alongside DisregardNamespacePolicy","Or include collection names in the interest so collection policies exist and can be considered","Fix the client code path that unconditionally sets DisregardNamespacePolicy"],"exampleFix":"// before\ncc := &discovery.ChaincodeInterest_Chaincode{Name: \"mycc\", DisregardNamespacePolicy: true}\n// after\ncc := &discovery.ChaincodeInterest_Chaincode{Name: \"mycc\"} // or add KeyPolicies/Collections","handlingStrategy":"validation","validationCode":"if cc.DisregardNamespacePolicy && len(cc.KeyPolicies) == 0 && len(cc.CollectionNames) == 0 {\n  return errors.New(\"DisregardNamespacePolicy set without key or collection policies\")\n}","typeGuard":null,"tryCatchPattern":"peers, err := client.PeersForEndorsement(ctx, interest)\nif err != nil && strings.Contains(err.Error(), \"requested to disregard\") {\n  // clear DisregardNamespacePolicy or attach key/collection policies and retry\n}","preventionTips":["Never set DisregardNamespacePolicy for plain chaincode queries","Always pair it with KeyPolicies or collection names","Review SDK builders that might set the flag unconditionally"],"tags":["fabric","discovery","chaincode-interest","client-bug"],"backgroundTag":"invalid-request-parameter","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"}