hyperledger/fabric · error
failed to retrieve policy manager for channel %s
Error message
failed to retrieve policy manager for channel %s
What it means
ApplicationPolicyEvaluator.New obtains the channel's policy manager from channelPolicyManagerGetter.Manager(channel); when it returns nil the channel has no policy manager available. This means the evaluator cannot resolve any channel-config policy references for that channel.
Source
Thrown at core/policy/application.go:118
func (d *dynamicPolicyManager) GetPolicy(id string) (policies.Policy, bool) {
mgr := d.channelPolicyManagerGetter.Manager(d.channelID)
if mgr == nil {
// this will never happen - if we are here we
// managed to retrieve the policy manager for
// this channel once, and so by the way the
// channel config is managed, we cannot fail.
panic("programming error")
}
return mgr.GetPolicy(id)
}
// New returns an evaluator for application policies
func New(deserializer msp.IdentityDeserializer, channel string, channelPolicyManagerGetter policies.ChannelPolicyManagerGetter) (*ApplicationPolicyEvaluator, error) {
mgr := channelPolicyManagerGetter.Manager(channel)
if mgr == nil {
return nil, errors.Errorf("failed to retrieve policy manager for channel %s", channel)
}
return &ApplicationPolicyEvaluator{
signaturePolicyProvider: &cauthdsl.EnvelopeBasedPolicyProvider{Deserializer: deserializer},
channelPolicyReferenceProvider: &ChannelPolicyReferenceProviderImpl{Manager: &dynamicPolicyManager{
channelID: channel,
channelPolicyManagerGetter: channelPolicyManagerGetter,
}},
}, nil
}
func (a *ApplicationPolicyEvaluator) evaluateSignaturePolicy(signaturePolicy *common.SignaturePolicyEnvelope, signatureSet []*protoutil.SignedData) error {
p, err := a.signaturePolicyProvider.NewPolicy(signaturePolicy)
if err != nil {
return errors.WithMessage(err, "could not create evaluator for signature policy")
}
return p.EvaluateSignedData(signatureSet)View on GitHub (pinned to 2736b63f8f)
Solutions
- Verify the channel ID passed to New matches an existing, joined channel (peer channel list)
- Ensure the channel has been joined/initialized so its policy manager bundle is loaded before constructing the evaluator
- If using the API programmatically, use a ChannelPolicyManagerGetter backed by the channel's config bundle (e.g., via peer.Channel), not a stub returning nil
- Check ordering/config-update completed so the channel config includes an Application/Policy manager
Example fix
// before
evaluator, err := policy.New(deserializer, "mychanl", getter)
// after
evaluator, err := policy.New(deserializer, "mychannel", getter)
if err != nil {
// channel not joined or policy manager missing
} Defensive patterns
Strategy: validation
Validate before calling
if mgr := channelPolicyManagerGetter.Manager(channel); mgr == nil {
return fmt.Errorf("channel %s not joined or policy manager unavailable; refusing to build evaluator", channel)
} Type guard
func hasChannelManager(g policies.ChannelPolicyManagerGetter, ch string) bool {
return g.Manager(ch) != nil
} Try / catch
evaluator, err := policy.New(deserializer, channel, getter)
if err != nil {
if strings.Contains(err.Error(), "failed to retrieve policy manager for channel") {
// join channel / wait for initialization, then retry
}
return err
} Prevention
- Confirm channel ID spelling and that the peer joined the channel before constructing evaluators
- Sequence plugin init after channel bundles are loaded
- Use the peer's real channel registry as the policy manager getter in tests, not nil-returning stubs
When it happens
Trigger: Calling New (directly or via initPlugin when building an endorsement/validation plugin) with a channel ID whose bundle/policy manager is not registered — unknown channel, channel not yet initialized, or deserializer/channel mismatch.
Common situations: Chaincode/plugin invoked on a channel name that is misspelled or does not exist, evaluator constructed before the channel config was committed, tests wiring a mock ChannelPolicyManagerGetter that returns nil.
Related errors
- Failed to get policy manager for channel [%s]
- specified --channelID %s does not match channel ID %s in con
- specified --channelID %s does not match channel ID %s in con
- Empty policy element
- missing policy at path: %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/6e4b1f6fb0414f92.
Report an issue: GitHub.