hyperledger/fabric · error

Invalid policy name during check policy on channel [%s]. Nam

Error message

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

What it means

policyChecker.CheckPolicy validates a signed proposal against a named channel policy. When the policyName argument is an empty string it rejects the request with this message, because an empty name cannot resolve to any configured policy.

Source

Thrown at core/policy/policy.go:67

// NewPolicyChecker creates a new instance of PolicyChecker
func NewPolicyChecker(channelPolicyManagerGetter policies.ChannelPolicyManagerGetter, localMSP msp.MSP) PolicyChecker {
	return &policyChecker{
		channelPolicyManagerGetter: channelPolicyManagerGetter,
		localMSP:                   localMSP,
		principalGetter:            &localMSPPrincipalGetter{localMSP: localMSP},
	}
}

// CheckPolicy checks that the passed signed proposal is valid with the respect to
// passed policy on the passed channel.
func (p *policyChecker) CheckPolicy(channelID, policyName string, signedProp *pb.SignedProposal) error {
	if channelID == "" {
		return p.CheckPolicyNoChannel(policyName, signedProp)
	}

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

	if signedProp == nil {
		return fmt.Errorf("Invalid signed proposal 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)
	}

	// Prepare SignedData
	proposal, err := protoutil.UnmarshalProposal(signedProp.ProposalBytes)
	if err != nil {
		return fmt.Errorf("Failing extracting proposal during check policy on channel [%s] with policy [%s]: [%s]", channelID, policyName, err)
	}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Pass a real policy name defined in the channel config (e.g., 'Readers', 'Writers', or a custom policy)
  2. Verify the source of the policy name (lifecycle resource policy, ACL entry) is populated before calling CheckPolicy
  3. Fail fast in your own code: reject empty policyName strings before invoking CheckPolicy
  4. Check configtx.yaml that the named policy actually exists for the channel

Example fix

// before
err := checker.CheckPolicy(channelID, policyName, signedProp) // policyName == ""
// after
if policyName == "" {
    return errors.New("policy name must be configured before CheckPolicy")
}
err := checker.CheckPolicy(channelID, policyName, signedProp)
Defensive patterns

Strategy: validation

Validate before calling

if policyName == "" {
    return errors.New("CheckPolicy requires a non-empty policy name")
}
if err := checker.CheckPolicy(channelID, policyName, signedProp); err != nil { return err }

Type guard

func hasPolicyName(name string) bool { return name != "" }

Try / catch

if err := checker.CheckPolicy(channelID, policyName, signedProp); err != nil {
    if strings.HasPrefix(err.Error(), "Invalid policy name during check policy") {
        // populate the policy name from channel/ACL config before retrying
    }
    return err
}

Prevention

When it happens

Trigger: Calling CheckPolicy(channelID, "", signedProp) — e.g., a caller extracting the policy name from a resource-based ACL/endorsement policy that was never populated.

Common situations: System chaincode or middleware passing through an unconfigured policy name, resource policies in the lifecycle database left empty, upstream code decoding a proposal where the policy name field was omitted.

Related errors


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