{"record":{"id":"2c577c0e634818ea","repo":"hyperledger/fabric","slug":"could-not-retrieve-policy-for-reference-s-on-ch","errorCode":null,"errorMessage":"could not retrieve policy for reference '%s' on channel '%s'","messagePattern":"could not retrieve policy for reference '(.+?)' on channel '(.+?)'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/metadata_provider.go","lineNumber":52,"sourceCode":"}\n\n// ChannelPolicyReferenceProvider is used to determine if a set of signature is valid and complies with a policy\ntype ChannelPolicyReferenceProvider interface {\n\t// NewPolicy creates a new policy based on the policy bytes\n\tNewPolicy(channelID, channelConfigPolicyReference string) (policies.Policy, error)\n}\n\ntype channelPolicyReferenceProviderImpl struct {\n\tChannelConfigSource\n}\n\n// NewPolicy implements the method of the same name of the ChannelPolicyReferenceProvider interface\nfunc (c *channelPolicyReferenceProviderImpl) NewPolicy(channelID, channelConfigPolicyReference string) (policies.Policy, error) {\n\tcc := c.GetStableChannelConfig(channelID)\n\tpm := cc.PolicyManager()\n\tp, ok := pm.GetPolicy(channelConfigPolicyReference)\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"could not retrieve policy for reference '%s' on channel '%s'\", channelConfigPolicyReference, channelID)\n\t}\n\n\treturn p, nil\n}\n\n// NewMetadataProvider returns a new MetadataProvider instance\nfunc NewMetadataProvider(cip ChaincodeInfoProvider, lmp LegacyMetadataProvider, ccs ChannelConfigSource) *MetadataProvider {\n\treturn &MetadataProvider{\n\t\tChaincodeInfoProvider:  cip,\n\t\tLegacyMetadataProvider: lmp,\n\t\tChannelPolicyReferenceProvider: &channelPolicyReferenceProviderImpl{\n\t\t\tChannelConfigSource: ccs,\n\t\t},\n\t}\n}\n\ntype MetadataProvider struct {\n\tChaincodeInfoProvider          ChaincodeInfoProvider","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/metadata_provider.go#L34-L70","documentation":"channelPolicyReferenceProviderImpl.NewPolicy resolves a channel-config policy reference to a policies.Policy via the channel's PolicyManager. If no policy exists under that reference name on the channel config, the lookup fails and this error is thrown. It means the policy name used (e.g. as endorsement policy reference) is not defined in the channel configuration.","triggerScenarios":"Endorsement policy given as '/Channel/Application/SomePolicy' or 'channelconfig-policy-name' that does not exist in the channel config; MetadataProvider building discovery/commit metadata resolves the reference via pm.GetPolicy and gets ok=false.","commonSituations":"Typo in policy path (e.g. /Channel/Application/LifecycleEndorsement misspelled); policy defined at Organization level but referenced at Channel level; policy removed in a config update while chaincodes still reference it; referencing the policy on a different channel where it is not defined.","solutions":["Check the reference against the channel config (configtxlator or 'peer channel fetch config') and fix the name/path","Use a policy that exists, e.g. /Channel/Application/Endorsement or majority endorsement via 'peer lifecycle chaincode approveformyorg -E'","Update the chaincode definition/approval to reference a valid policy after any config update that removed policies","Ensure you reference the policy on the correct channel"],"exampleFix":"// before: reference to nonexistent policy\npeer lifecycle chaincode approveformyorg -C mychannel --name mycc -E /Channel/Application/MyTypoPolicy\n// error\n// after: use an existing channel policy\npeer lifecycle chaincode approveformyorg -C mychannel --name mycc -E /Channel/Application/Endorsement","handlingStrategy":"validation","validationCode":"# Before using a policy reference, confirm it exists in channel config\npeer channel fetch config config.block -c mychannel\nconfigtxlator proto_decode --input config.block --type common.Config > config.json\njq '.channel_group.groups.Application.policies | keys' config.json","typeGuard":null,"tryCatchPattern":"p, err := provider.NewPolicy(channelID, ref)\nif err != nil {\n  if strings.Contains(err.Error(), \"could not retrieve policy for reference\") {\n    // fall back to a default signature policy or fail fast with a clear message\n  }\n}","preventionTips":["List channel policies with configtxlator before referencing them","Use exact paths like /Channel/Application/Endorsement","Re-check references after any channel config update","Prefer explicit signature policies over channel references when unsure"],"tags":["fabric","policy","channel-config","not-found"],"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"}