hyperledger/fabric · error

Invalid policy name during check policy on signed data on ch

Error message

Invalid policy name during check policy on signed data on channel [%s]. Name must be different from nil.

What it means

Returned by CheckPolicyBySignedData when the policyName parameter is an empty string. The channel ID was valid, but no policy name was supplied, so there is nothing to evaluate. The message includes the channel for easier diagnosis.

Source

Thrown at core/policy/policy.go:163

	err = id.SatisfiesPrincipal(principal)
	if err != nil {
		logger.Warnw("Failed verifying that proposal's creator satisfies local MSP principal during channelless check policy", "error", err, "policyName", policyName, "requiredPrincipal", principal, "signingIdentity", protoutil.LogMessageForSerializedIdentity(shdr.Creator))
		return fmt.Errorf("Failed verifying that proposal's creator satisfies local MSP principal during channelless check policy with policy [%s]: [%s]", policyName, err)
	}

	// Verify the signature
	return id.Verify(signedProp.ProposalBytes, signedProp.Signature)
}

// CheckPolicyBySignedData checks that the passed signed data is valid with the respect to
// passed policy on the passed channel.
func (p *policyChecker) CheckPolicyBySignedData(channelID, policyName string, sd []*protoutil.SignedData) error {
	if channelID == "" {
		return errors.New("Invalid channel ID name during check policy on signed data. Name must be different from nil.")
	}

	if policyName == "" {
		return fmt.Errorf("Invalid policy name during check policy on signed data on channel [%s]. Name must be different from nil.", channelID)
	}

	if sd == nil {
		return fmt.Errorf("Invalid signed data during check policy on channel [%s] with policy [%s]", channelID, policyName)
	}

	// Get Policy
	policyManager := p.channelPolicyManagerGetter.Manager(channelID)
	if policyManager == nil {
		return fmt.Errorf("Failed to get policy manager for channel [%s]", channelID)
	}

	// Recall that get policy always returns a policy object
	policy, _ := policyManager.GetPolicy(policyName)

	// Evaluate the policy
	err := policy.EvaluateSignedData(sd)
	if err != nil {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Pass a valid policy name such as "CHANNEL_READERS" or "CHANNEL_WRITERS".
  2. Fix the code/config that derives the policy name from the proposal header so it is populated.
  3. Verify the named policy exists in the channel's configtx if unsure which name to use.

Example fix

// before
err := checker.CheckPolicyBySignedData("mychannel", "", sd)
// after
if policyName == "" { return errors.New("policyName is required") }
err := checker.CheckPolicyBySignedData("mychannel", "CHANNEL_READERS", sd)
Defensive patterns

Strategy: validation

Validate before calling

if policyName == "" {
    return errors.New("policy name must be non-empty (e.g. CHANNEL_READERS) before calling CheckPolicyBySignedData")
}

Type guard

func validPolicyName(name string) bool {
    return name == "CHANNEL_READERS" || name == "CHANNEL_WRITERS" || name == "CHANNEL_ADMINS" || len(name) > 0
}

Prevention

When it happens

Trigger: Calling CheckPolicyBySignedData(channelID, "", sd) directly, or via CheckPolicy when the proposal's header carries an empty policy name (e.g. missing/blank policy reference extracted from the proposal header).

Common situations: SDK proposal header built without the policy name field; config key for policy name resolves to empty string; typos yielding blank value after trimming.

Related errors


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