hyperledger/fabric · error

requested to disregard chaincode %s's policy but key and col

Error message

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

What it means

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.

Source

Thrown at discovery/endorsement/endorsement.go:274

	logger.Debugf("No state based policies requested")

	return nil, nil
}

func (ea *endorsementAnalyzer) computePrincipalSets(channelID common.ChannelID, interest *peer.ChaincodeInterest) (policies.PrincipalSets, error) {
	sessionLogger := logger.With("channel", string(channelID))
	var inquireablePoliciesForChaincodeAndCollections []policies.InquireablePolicy
	for _, chaincode := range interest.Chaincodes {
		policies := ea.PoliciesByChaincode(string(channelID), chaincode.Name, chaincode.CollectionNames...)
		if len(policies) == 0 {
			sessionLogger.Debug("Policy for chaincode '", chaincode, "'doesn't exist")
			return nil, errors.New("policy not found")
		}
		if chaincode.DisregardNamespacePolicy && len(chaincode.KeyPolicies) == 0 && len(policies) == 1 {
			sessionLogger.Warnf("Client requested to disregard chaincode %s's policy, but it did not specify any "+
				"collection policies or key policies. This is probably a bug in the client side code, as the client should"+
				"either not specify DisregardNamespacePolicy, or specify at least one key policy or at least one collection policy", chaincode.Name)
			return nil, errors.Errorf("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", chaincode.Name)
		}
		if chaincode.DisregardNamespacePolicy {
			if len(policies) == 1 {
				sessionLogger.Debugf("Client requested to disregard the namespace policy for chaincode %s,"+
					" and no collection policies are present", chaincode.Name)
				continue
			}
			sessionLogger.Debugf("Client requested to disregard the namespace policy for chaincode %s,"+
				" however there exist %d collection policies taken into account", chaincode.Name, len(policies)-1)
			policies = policies[1:]
		}
		inquireablePoliciesForChaincodeAndCollections = append(inquireablePoliciesForChaincodeAndCollections, policies...)
	}

	var cpss []inquire.ComparablePrincipalSets

	for _, policy := range inquireablePoliciesForChaincodeAndCollections {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Set DisregardNamespacePolicy=false (leave it default) for plain chaincode endorsement requests
  2. Or supply at least one KeyPolicy (state-based endorsement policy) alongside DisregardNamespacePolicy
  3. Or include collection names in the interest so collection policies exist and can be considered
  4. Fix the client code path that unconditionally sets DisregardNamespacePolicy

Example fix

// before
cc := &discovery.ChaincodeInterest_Chaincode{Name: "mycc", DisregardNamespacePolicy: true}
// after
cc := &discovery.ChaincodeInterest_Chaincode{Name: "mycc"} // or add KeyPolicies/Collections
Defensive patterns

Strategy: validation

Validate before calling

if cc.DisregardNamespacePolicy && len(cc.KeyPolicies) == 0 && len(cc.CollectionNames) == 0 {
  return errors.New("DisregardNamespacePolicy set without key or collection policies")
}

Try / catch

peers, err := client.PeersForEndorsement(ctx, interest)
if err != nil && strings.Contains(err.Error(), "requested to disregard") {
  // clear DisregardNamespacePolicy or attach key/collection policies and retry
}

Prevention

When it happens

Trigger: 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.

Common situations: SDK code that always sets DisregardNamespacePolicy for 'private data' style calls but forgot to attach collection names or key policies; misconfigured ChaincodeInterest builders.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/9e363a98e9193a80. Report an issue: GitHub.