{"record":{"id":"bfdb7b735db92b51","repo":"hyperledger/fabric","slug":"no-such-policy-s","errorCode":null,"errorMessage":"no such policy: '%s'","messagePattern":"no such policy: '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/policies/policy.go","lineNumber":250,"sourceCode":"\t}\n\n\tfor groupName, manager := range managers {\n\t\tfor policyName, policy := range manager.Policies {\n\t\t\tpolicies[groupName+PathSeparator+policyName] = policy\n\t\t}\n\t}\n\n\treturn &ManagerImpl{\n\t\tpath:     path,\n\t\tPolicies: policies,\n\t\tmanagers: managers,\n\t}, nil\n}\n\ntype rejectPolicy string\n\nfunc (rp rejectPolicy) EvaluateSignedData(signedData []*protoutil.SignedData) error {\n\treturn errors.Errorf(\"no such policy: '%s'\", rp)\n}\n\nfunc (rp rejectPolicy) EvaluateIdentities(identities []mspi.Identity) error {\n\treturn errors.Errorf(\"no such policy: '%s'\", rp)\n}\n\n// Manager returns the sub-policy manager for a given path and whether it exists\nfunc (pm *ManagerImpl) Manager(path []string) (Manager, bool) {\n\tlogger.Debugf(\"Manager %s looking up path %v\", pm.path, path)\n\tfor manager := range pm.managers {\n\t\tlogger.Debugf(\"Manager %s has managers %s\", pm.path, manager)\n\t}\n\tif len(path) == 0 {\n\t\treturn pm, true\n\t}\n\n\tm, ok := pm.managers[path[0]]\n\tif !ok {","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/policies/policy.go#L232-L268","documentation":"rejectPolicy is a sentinel Policy that always fails. EvaluateSignedData on it throws 'no such policy' carrying the policy name; it is used so lookups for missing policies return a policy whose evaluation always errors.","triggerScenarios":"Calling ManagerImpl.GetPolicy(name) for a policy name that does not exist in the manager, then invoking EvaluateSignedData on the returned rejectPolicy.","commonSituations":"Requesting 'Writers'/'Readers'/'Admins' policies misspelled or absent from channel config; evaluating a policy from an older channel that has since been renamed; application code assuming a default policy exists.","solutions":["Use Manager(path) to check policy existence before evaluating, or handle the error as 'policy absent'","Fix the policy name to match one defined in channel config (case-sensitive)","Add the missing policy via a channel configuration update"],"exampleFix":"// before\np, _ := mgr.GetPolicy(\"Writters\")\nerr := p.EvaluateSignedData(sd) // 'no such policy'\n// after\nif _, ok := mgr.Manager(nil); ok {\n  p, _ := mgr.GetPolicy(\"Writers\")\n  err := p.EvaluateSignedData(sd)\n}","handlingStrategy":"type-guard","validationCode":"// Check existence before using GetPolicy output\nif _, ok := mgr.Manager(path); !ok {\n  return fmt.Errorf(\"no policy manager at path %v\", path)\n}","typeGuard":"func isRejectPolicy(p policies.Policy) bool {\n  _, ok := p.(policies.rejectPolicy)\n  return ok\n}","tryCatchPattern":"err := policy.EvaluateSignedData(sd)\nif err != nil && strings.Contains(err.Error(), \"no such policy\") {\n  // policy absent from config: surface a config error, do not retry\n}","preventionTips":["Spell policy names exactly as defined in channel config (case-sensitive)","Check Manager(path) existence before GetPolicy","Confirm policies exist after every channel config update"],"tags":["hyperledger-fabric","policy-evaluation","missing-policy"],"backgroundTag":"no-such-policy","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"}