{"record":{"id":"33fd319a8b50a0d9","repo":"hyperledger/fabric","slug":"failed-to-retrieve-policy-for-reference-s","errorCode":null,"errorMessage":"failed to retrieve policy for reference %s","messagePattern":"failed to retrieve policy for reference (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/policy/application.go","lineNumber":88,"sourceCode":"type ApplicationPolicyEvaluator struct {\n\tsignaturePolicyProvider        SignaturePolicyProvider\n\tchannelPolicyReferenceProvider ChannelPolicyReferenceProvider\n}\n\n// Manager defines functions to interface with the policy manager of a channel\ntype Manager interface {\n\t// GetPolicy returns a policy and true if it was the policy requested, or false if it is the default policy\n\tGetPolicy(id string) (policies.Policy, bool)\n}\n\ntype ChannelPolicyReferenceProviderImpl struct {\n\tManager\n}\n\nfunc (c *ChannelPolicyReferenceProviderImpl) NewPolicy(channelConfigPolicyReference string) (policies.Policy, error) {\n\tp, ok := c.GetPolicy(channelConfigPolicyReference)\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"failed to retrieve policy for reference %s\", channelConfigPolicyReference)\n\t}\n\n\treturn p, nil\n}\n\n// dynamicPolicyManager implements a policy manager that\n// always acts on the latest config for this channel\ntype dynamicPolicyManager struct {\n\tchannelPolicyManagerGetter policies.ChannelPolicyManagerGetter\n\tchannelID                  string\n}\n\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","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/policy/application.go#L70-L106","documentation":"ChannelPolicyReferenceProviderImpl.NewPolicy resolves a policy by name from the channel config policy manager. If the named policy reference does not exist in the channel configuration, it returns this error. It means an ApplicationPolicy with a ChannelConfigPolicyReference points at a policy name that is not defined on that channel.","triggerScenarios":"Evaluating an ApplicationPolicy whose ChannelConfigPolicyReference string (e.g. '/Channel/Application/MyPolicy') does not match any policy defined in the channel's configtx; GetPolicy returns ok=false.","commonSituations":"Typo in the policy reference path, policy defined in one channel but endorsement/ACL on another channel references it, policy removed in a config update while still referenced by chaincode endorsement policy or ACLs.","solutions":["Check the exact policy reference string against policies defined in the channel config (configtxlator decode or `peer channel fetch config`)","Define the missing policy in configtx.yaml under the appropriate section (Application/Orderer policies) and update channel config","Verify the chaincode endorsement policy / ACL references a policy that exists in this specific channel","Fix path/case typos — policy references are path-like strings such as /Channel/Application/Readers"],"exampleFix":"// before\npolicy := &peer.ApplicationPolicy{Type: &peer.ApplicationPolicy_ChannelConfigPolicyReference{\n    ChannelConfigPolicyReference: \"/Channel/Application/Writters\"}}\n// after (policy name that exists in channel config)\npolicy := &peer.ApplicationPolicy{Type: &peer.ApplicationPolicy_ChannelConfigPolicyReference{\n    ChannelConfigPolicyReference: \"/Channel/Application/Writers\"}}","handlingStrategy":"validation","validationCode":"func policyExists(getter policies.ChannelPolicyManagerGetter, channel, ref string) error {\n    mgr := getter.Manager(channel)\n    if mgr == nil { return fmt.Errorf(\"no policy manager for channel %s\", channel) }\n    if _, ok := mgr.GetPolicy(ref); !ok {\n        return fmt.Errorf(\"policy %q not defined in channel %s config\", ref, channel)\n    }\n    return nil\n}","typeGuard":"func policyResolvable(mgr policies.Manager, ref string) bool {\n    _, ok := mgr.GetPolicy(ref)\n    return ok\n}","tryCatchPattern":"pol, err := provider.NewPolicy(ref)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to retrieve policy for reference\") {\n        // fetch and decode channel config, fix or define the policy, then retry\n    }\n    return err\n}","preventionTips":["Keep policy reference strings (e.g., /Channel/Application/Writers) in constants, not ad-hoc literals","Cross-check ACL and endorsement policy references against the channel config on every config update","Decode channel config with configtxlator in CI to assert referenced policies exist","When removing a policy in a config update, first migrate all references"],"tags":["hyperledger-fabric","policy","channel-config"],"backgroundTag":"policy-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"}