{"record":{"id":"cd67141e49106e8a","repo":"hyperledger/fabric","slug":"invalid-policy-name-during-check-policy-on-channel","errorCode":null,"errorMessage":"Invalid policy name during check policy on channel [%s]. Name must be different from nil.","messagePattern":"Invalid policy name during check policy on channel \\[(.+?)\\]\\. Name must be different from nil\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/policy/policy.go","lineNumber":67,"sourceCode":"\n// NewPolicyChecker creates a new instance of PolicyChecker\nfunc NewPolicyChecker(channelPolicyManagerGetter policies.ChannelPolicyManagerGetter, localMSP msp.MSP) PolicyChecker {\n\treturn &policyChecker{\n\t\tchannelPolicyManagerGetter: channelPolicyManagerGetter,\n\t\tlocalMSP:                   localMSP,\n\t\tprincipalGetter:            &localMSPPrincipalGetter{localMSP: localMSP},\n\t}\n}\n\n// CheckPolicy checks that the passed signed proposal is valid with the respect to\n// passed policy on the passed channel.\nfunc (p *policyChecker) CheckPolicy(channelID, policyName string, signedProp *pb.SignedProposal) error {\n\tif channelID == \"\" {\n\t\treturn p.CheckPolicyNoChannel(policyName, signedProp)\n\t}\n\n\tif policyName == \"\" {\n\t\treturn fmt.Errorf(\"Invalid policy name during check policy on channel [%s]. Name must be different from nil.\", channelID)\n\t}\n\n\tif signedProp == nil {\n\t\treturn fmt.Errorf(\"Invalid signed proposal during check policy on channel [%s] with policy [%s]\", channelID, policyName)\n\t}\n\n\t// Get Policy\n\tpolicyManager := p.channelPolicyManagerGetter.Manager(channelID)\n\tif policyManager == nil {\n\t\treturn fmt.Errorf(\"Failed to get policy manager for channel [%s]\", channelID)\n\t}\n\n\t// Prepare SignedData\n\tproposal, err := protoutil.UnmarshalProposal(signedProp.ProposalBytes)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failing extracting proposal during check policy on channel [%s] with policy [%s]: [%s]\", channelID, policyName, err)\n\t}\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/policy/policy.go#L49-L85","documentation":"policyChecker.CheckPolicy validates a signed proposal against a named channel policy. When the policyName argument is an empty string it rejects the request with this message, because an empty name cannot resolve to any configured policy.","triggerScenarios":"Calling CheckPolicy(channelID, \"\", signedProp) — e.g., a caller extracting the policy name from a resource-based ACL/endorsement policy that was never populated.","commonSituations":"System chaincode or middleware passing through an unconfigured policy name, resource policies in the lifecycle database left empty, upstream code decoding a proposal where the policy name field was omitted.","solutions":["Pass a real policy name defined in the channel config (e.g., 'Readers', 'Writers', or a custom policy)","Verify the source of the policy name (lifecycle resource policy, ACL entry) is populated before calling CheckPolicy","Fail fast in your own code: reject empty policyName strings before invoking CheckPolicy","Check configtx.yaml that the named policy actually exists for the channel"],"exampleFix":"// before\nerr := checker.CheckPolicy(channelID, policyName, signedProp) // policyName == \"\"\n// after\nif policyName == \"\" {\n    return errors.New(\"policy name must be configured before CheckPolicy\")\n}\nerr := checker.CheckPolicy(channelID, policyName, signedProp)","handlingStrategy":"validation","validationCode":"if policyName == \"\" {\n    return errors.New(\"CheckPolicy requires a non-empty policy name\")\n}\nif err := checker.CheckPolicy(channelID, policyName, signedProp); err != nil { return err }","typeGuard":"func hasPolicyName(name string) bool { return name != \"\" }","tryCatchPattern":"if err := checker.CheckPolicy(channelID, policyName, signedProp); err != nil {\n    if strings.HasPrefix(err.Error(), \"Invalid policy name during check policy\") {\n        // populate the policy name from channel/ACL config before retrying\n    }\n    return err\n}","preventionTips":["Validate inputs (non-empty policyName, non-nil signedProp) before calling CheckPolicy","Source policy names from channel config constants or lifecycle metadata, checked at startup","Add unit tests that exercise CheckPolicy with every configured policy name"],"tags":["hyperledger-fabric","policy","validation"],"backgroundTag":"missing-policy-name","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"}