{"record":{"id":"6e4b1f6fb0414f92","repo":"hyperledger/fabric","slug":"failed-to-retrieve-policy-manager-for-channel-s","errorCode":null,"errorMessage":"failed to retrieve policy manager for channel %s","messagePattern":"failed to retrieve policy manager for channel (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/policy/application.go","lineNumber":118,"sourceCode":"\nfunc (d *dynamicPolicyManager) GetPolicy(id string) (policies.Policy, bool) {\n\tmgr := d.channelPolicyManagerGetter.Manager(d.channelID)\n\tif mgr == nil {\n\t\t// this will never happen - if we are here we\n\t\t// managed to retrieve the policy manager for\n\t\t// this channel once, and so by the way the\n\t\t// channel config is managed, we cannot fail.\n\t\tpanic(\"programming error\")\n\t}\n\n\treturn mgr.GetPolicy(id)\n}\n\n// New returns an evaluator for application policies\nfunc New(deserializer msp.IdentityDeserializer, channel string, channelPolicyManagerGetter policies.ChannelPolicyManagerGetter) (*ApplicationPolicyEvaluator, error) {\n\tmgr := channelPolicyManagerGetter.Manager(channel)\n\tif mgr == nil {\n\t\treturn nil, errors.Errorf(\"failed to retrieve policy manager for channel %s\", channel)\n\t}\n\n\treturn &ApplicationPolicyEvaluator{\n\t\tsignaturePolicyProvider: &cauthdsl.EnvelopeBasedPolicyProvider{Deserializer: deserializer},\n\t\tchannelPolicyReferenceProvider: &ChannelPolicyReferenceProviderImpl{Manager: &dynamicPolicyManager{\n\t\t\tchannelID:                  channel,\n\t\t\tchannelPolicyManagerGetter: channelPolicyManagerGetter,\n\t\t}},\n\t}, nil\n}\n\nfunc (a *ApplicationPolicyEvaluator) evaluateSignaturePolicy(signaturePolicy *common.SignaturePolicyEnvelope, signatureSet []*protoutil.SignedData) error {\n\tp, err := a.signaturePolicyProvider.NewPolicy(signaturePolicy)\n\tif err != nil {\n\t\treturn errors.WithMessage(err, \"could not create evaluator for signature policy\")\n\t}\n\n\treturn p.EvaluateSignedData(signatureSet)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/policy/application.go#L100-L136","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nevaluator, err := policy.New(deserializer, \"mychanl\", getter)\n// after\nevaluator, err := policy.New(deserializer, \"mychannel\", getter)\nif err != nil {\n    // channel not joined or policy manager missing\n}","handlingStrategy":"validation","validationCode":"if mgr := channelPolicyManagerGetter.Manager(channel); mgr == nil {\n    return fmt.Errorf(\"channel %s not joined or policy manager unavailable; refusing to build evaluator\", channel)\n}","typeGuard":"func hasChannelManager(g policies.ChannelPolicyManagerGetter, ch string) bool {\n    return g.Manager(ch) != nil\n}","tryCatchPattern":"evaluator, err := policy.New(deserializer, channel, getter)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to retrieve policy manager for channel\") {\n        // join channel / wait for initialization, then retry\n    }\n    return err\n}","preventionTips":["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"],"tags":["hyperledger-fabric","policy","channel"],"backgroundTag":"policy-manager-not-found","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}