{"record":{"id":"a483a6a766e5fffe","repo":"hyperledger/fabric","slug":"policy-fetcher-not-passed-in-init","errorCode":null,"errorMessage":"policy fetcher not passed in init","messagePattern":"policy fetcher not passed in init","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/default_validation.go","lineNumber":137,"sourceCode":"\t\t}\n\t\tif policyEvaluator, isPolicyFetcher := dep.(vp.PolicyEvaluator); isPolicyFetcher {\n\t\t\tpe = policyEvaluator\n\t\t}\n\t\tif collectionResources, isCollectionResources := dep.(plugindispatcher.CollectionResources); isCollectionResources {\n\t\t\tcor = collectionResources\n\t\t}\n\t}\n\tif sf == nil {\n\t\treturn errors.New(\"stateFetcher not passed in init\")\n\t}\n\tif d == nil {\n\t\treturn errors.New(\"identityDeserializer not passed in init\")\n\t}\n\tif c == nil {\n\t\treturn errors.New(\"capabilities not passed in init\")\n\t}\n\tif pe == nil {\n\t\treturn errors.New(\"policy fetcher not passed in init\")\n\t}\n\tif cor == nil {\n\t\treturn errors.New(\"collection resources not passed in init\")\n\t}\n\n\tv.Capabilities = c\n\tv.TxValidatorV1_2 = v12.New(c, sf, d, pe)\n\tv.TxValidatorV1_3 = v13.New(c, sf, d, pe)\n\tv.TxValidatorV2_0 = v20.New(c, sf, d, pe, cor)\n\n\treturn nil\n}\n","sourceCodeStart":119,"sourceCodeEnd":150,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/default_validation.go#L119-L150","documentation":"Init() returns this error when the policy fetcher (PolicyFetcher, pe) is nil. During validation the handler resolves the endorsement and instantiation policies from channel policy manager by name; without a policy fetcher it cannot evaluate them. Initialization fails immediately with this message.","triggerScenarios":"Calling Init() with pe == nil: constructing the built-in validation handler without a PolicyFetcher dependency.","commonSituations":"Custom validation plugin wiring that skips policy manager hookup; peers whose channel policy manager is initialized after validators; incomplete test dependency sets.","solutions":["Provide a PolicyFetcher (channel policy manager) in the dependencies passed to Init()","Ensure the peer startup order creates the policy manager before instantiating validation handlers","Audit DI wiring after refactorings to ensure pe is never nil"],"exampleFix":"// before\nerr := handler.Init(sf, deserializer, caps, nil, collectionResources)\n// after\npe := policy.NewPolicyFetcher(channelPolicyManagerGetter)\nerr := handler.Init(sf, deserializer, caps, pe, collectionResources)","handlingStrategy":"validation","validationCode":"if pe == nil {\n    return errors.New(\"cannot init validation handler: PolicyFetcher dependency is nil\")\n}\nerr := handler.Init(sf, d, c, pe, cor)","typeGuard":"func depsComplete(pe PolicyFetcher) bool { return pe != nil }","tryCatchPattern":null,"preventionTips":["Initialize the channel policy manager before validation handlers","Use a constructor helper that takes the policy manager and fails fast if nil","Cover Init in integration tests with the real peer startup sequence"],"tags":["go","initialization","dependency-injection","policy"],"backgroundTag":"missing-dependency-in-init","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"}