hyperledger/fabric · error
invalid policy name during channelless check policy. Name mu
Error message
invalid policy name during channelless check policy. Name must be different from nil.
What it means
CheckPolicyNoChannelBySignedData rejects an empty policy name before doing any work, because a channelless policy check resolves the policy name to an MSPPrincipal on the local MSP; an empty name identifies no principal. The message's 'different from nil' is legacy Go phrasing for 'must not be empty'. It is a pure input-validation error, thrown synchronously at the first guard in the function.
Source
Thrown at core/policy/policy.go:193
// Recall that get policy always returns a policy object
policy, _ := policyManager.GetPolicy(policyName)
// Evaluate the policy
err := policy.EvaluateSignedData(sd)
if err != nil {
logger.Warnw("Failed evaluating policy on signed data", "error", err, "policyName", policyName, "identities", protoutil.LogMessageForSerializedIdentities(sd))
return fmt.Errorf("Failed evaluating policy on signed data during check policy on channel [%s] with policy [%s]: [%s]", channelID, policyName, err)
}
return nil
}
// CheckPolicyNoChannelBySignedData checks that the passed signed data are valid with the respect to
// passed policy on the local MSP.
func (p *policyChecker) CheckPolicyNoChannelBySignedData(policyName string, signedData []*protoutil.SignedData) error {
if policyName == "" {
return errors.New("invalid policy name during channelless check policy. Name must be different from nil.")
}
if len(signedData) == 0 {
return fmt.Errorf("no signed data during channelless check policy with policy [%s]", policyName)
}
for _, data := range signedData {
// Deserialize identity with the local MSP
id, err := p.localMSP.DeserializeIdentity(data.Identity)
if err != nil {
logger.Warnw("Failed deserializing signed data identity during channelless check policy", "error", err, "policyName", policyName, "identity", protoutil.LogMessageForSerializedIdentity(data.Identity))
return fmt.Errorf("failed deserializing signed data identity during channelless check policy with policy [%s]: [%s]", policyName, err)
}
// Load MSPPrincipal for policy
principal, err := p.principalGetter.Get(policyName)
if err != nil {
return fmt.Errorf("failed getting local MSP principal during channelless check policy with policy [%s]: [%s]", policyName, err)View on GitHub (pinned to 2736b63f8f)
Solutions
- Pass a real local-MSP principal name, e.g. an MSP ID or a role-style principal string the MSPPrincipalGetter understands.
- Check the config/flag source for the policy name and fail fast with your own clear error when empty.
- If a channel-scoped check was intended, call CheckPolicyBySignedData with a non-empty channelID and a channel policy name (e.g. 'Writers') instead.
- Add a guard in your caller: if policyName == "" { return errors.New(...) } before invoking the checker.
Example fix
// before
err := policyChecker.CheckPolicyNoChannelBySignedData(policyName, sd) // policyName == ""
// after
if policyName == "" {
return errors.New("policy name must be configured for channelless policy check")
}
err := policyChecker.CheckPolicyNoChannelBySignedData(policyName, sd) Defensive patterns
Strategy: validation
Validate before calling
if policyName == "" {
return errors.New("policy name must be a non-empty MSP principal name for channelless check")
}
err := policyChecker.CheckPolicyNoChannelBySignedData(policyName, signedData) Type guard
func hasPolicyName(policyName string) bool { return strings.TrimSpace(policyName) != "" } Prevention
- Fail fast on empty config values when loading policy names from configuration.
- Distinguish channel-policy checks (CheckPolicy*) from channelless MSP-principal checks and never pass channel policy names to the latter.
- Trim whitespace from externally supplied policy names before use.
- Add unit tests covering the empty-name path.
When it happens
Trigger: Calling CheckPolicyNoChannelBySignedData("") with any signedData slice; typically a caller obtained policyName from an unset config value, an empty CLI flag, or a struct field that was never populated.
Common situations: System chaincode or CLI code passing a policy name sourced from configuration where the key is missing; callers that intended a channel-based check but routed through the channelless variant with default-empty variables; refactoring where a constant was accidentally removed.
Related errors
- failed getting local MSP principal during channelless check
- no signed data during channelless check policy with policy [
- nil request
- The required parameter 'name' is empty. Rerun the command wi
- The required parameter 'version' is empty. Rerun the command
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/0f66f46481906785.
Report an issue: GitHub.