hyperledger/fabric · error

policy fetcher not passed in init

Error message

policy fetcher not passed in init

What it means

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.

Source

Thrown at core/handlers/validation/builtin/default_validation.go:137

		}
		if policyEvaluator, isPolicyFetcher := dep.(vp.PolicyEvaluator); isPolicyFetcher {
			pe = policyEvaluator
		}
		if collectionResources, isCollectionResources := dep.(plugindispatcher.CollectionResources); isCollectionResources {
			cor = collectionResources
		}
	}
	if sf == nil {
		return errors.New("stateFetcher not passed in init")
	}
	if d == nil {
		return errors.New("identityDeserializer not passed in init")
	}
	if c == nil {
		return errors.New("capabilities not passed in init")
	}
	if pe == nil {
		return errors.New("policy fetcher not passed in init")
	}
	if cor == nil {
		return errors.New("collection resources not passed in init")
	}

	v.Capabilities = c
	v.TxValidatorV1_2 = v12.New(c, sf, d, pe)
	v.TxValidatorV1_3 = v13.New(c, sf, d, pe)
	v.TxValidatorV2_0 = v20.New(c, sf, d, pe, cor)

	return nil
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Provide a PolicyFetcher (channel policy manager) in the dependencies passed to Init()
  2. Ensure the peer startup order creates the policy manager before instantiating validation handlers
  3. Audit DI wiring after refactorings to ensure pe is never nil

Example fix

// before
err := handler.Init(sf, deserializer, caps, nil, collectionResources)
// after
pe := policy.NewPolicyFetcher(channelPolicyManagerGetter)
err := handler.Init(sf, deserializer, caps, pe, collectionResources)
Defensive patterns

Strategy: validation

Validate before calling

if pe == nil {
    return errors.New("cannot init validation handler: PolicyFetcher dependency is nil")
}
err := handler.Init(sf, d, c, pe, cor)

Type guard

func depsComplete(pe PolicyFetcher) bool { return pe != nil }

Prevention

When it happens

Trigger: Calling Init() with pe == nil: constructing the built-in validation handler without a PolicyFetcher dependency.

Common situations: Custom validation plugin wiring that skips policy manager hookup; peers whose channel policy manager is initialized after validators; incomplete test dependency sets.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/a483a6a766e5fffe. Report an issue: GitHub.