hyperledger/fabric · error
Invalid policy name during check policy on channel
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.
Solutions
- Pass a real policy name defined in the channel config (e.g., 'Readers', 'Writers', or a custom policy)
- Verify the source of the policy name (lifecycle resource policy, ACL entry) is populated before calling CheckPolicy
- Fail fast in your own code: reject empty policyName strings before invoking CheckPolicy
- 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
- Validate inputs (non-empty policyName, non-nil signedProp) before calling CheckPolicy
- Source policy names from channel config constants or lifecycle metadata, checked at startup
- Add unit tests that exercise CheckPolicy with every configured policy name
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
- Invalid policy name during channelless check policy. Name…
- Invalid signed proposal during channelless check policy…
- access denied
- at least one TransactionAction required
- Attempted to set the batch size absolute max bytes to an…
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/cd67141e49106e8a.
Report an issue: GitHub.
Appendix: 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)