hyperledger/fabric · error

policy %s at path %s has unknown policy type: %v

Error message

policy %s at path %s has unknown policy type: %v

What it means

For non-implicit-meta policies, NewManagerImpl looks up the registered provider by policy.Type (e.g. signature type). If no provider is registered for that type code, the policy cannot be built and this error names the type value.

Source

Thrown at common/policies/policy.go:219

	policies := make(map[string]Policy)
	for policyName, configPolicy := range root.Policies {
		policy := configPolicy.Policy
		if policy == nil {
			return nil, fmt.Errorf("policy %s at path %s was nil", policyName, path)
		}

		var cPolicy Policy

		if policy.Type == int32(cb.Policy_IMPLICIT_META) {
			imp, err := NewImplicitMetaPolicy(policy.Value, managers)
			if err != nil {
				return nil, errors.Wrapf(err, "implicit policy %s at path %s did not compile", policyName, path)
			}
			cPolicy = imp
		} else {
			provider, ok := providers[policy.Type]
			if !ok {
				return nil, fmt.Errorf("policy %s at path %s has unknown policy type: %v", policyName, path, policy.Type)
			}

			var err error
			cPolicy, _, err = provider.NewPolicy(policy.Value)
			if err != nil {
				return nil, errors.Wrapf(err, "policy %s at path %s did not compile", policyName, path)
			}
		}

		policies[policyName] = cPolicy

		logger.Debugf("Proposed new policy %s for %s", policyName, path)
	}

	for groupName, manager := range managers {
		for policyName, policy := range manager.Policies {
			policies[groupName+PathSeparator+policyName] = policy
		}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Register a provider for the policy type in the providers map passed to NewManagerImpl
  2. Change the policy type in config to a supported one (IMPLICIT_META or the signature type with a registered provider)
  3. Align Fabric tooling/runtime versions so the policy type is recognized

Example fix

// before
NewManagerImpl(root, "", map[int32]Provider{})
// after
NewManagerImpl(root, "", map[int32]Provider{int32(cb.Policy_SIGNATURE): &cauthdsl.Provider{}})
Defensive patterns

Strategy: validation

Validate before calling

for _, p := range configPolicies {
  if _, ok := providers[p.Type]; !ok {
    return fmt.Errorf("no provider registered for policy type %d", p.Type)
  }
}

Try / catch

mgr, err := policies.NewManagerImpl(root, path, providers)
if err != nil && strings.Contains(err.Error(), "unknown policy type") {
  return fmt.Errorf("register or map the policy type before building the manager: %w", err)
}

Prevention

When it happens

Trigger: Calling NewManagerImpl with a providers map lacking an entry for the numeric policy.Type stored in config, e.g. a policy with type 1 (signature) but no SignaturePolicy provider registered, or a type introduced by a newer Fabric version than the running code.

Common situations: Custom/extension policy types not supported by the bundled managers; version mismatch where config was created by newer Fabric tooling; incorrect Type field written by config generation tools.

Related errors


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