hyperledger/fabric · error

policy %s at path %s did not compile

Error message

policy %s at path %s did not compile

What it means

After a provider is found, NewManagerImpl calls provider.NewPolicy(policy.Value) to compile the policy body (e.g. a SignaturePolicyEnvelope). Compilation failures are wrapped with this message identifying the policy and config path.

Source

Thrown at common/policies/policy.go:225

		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
		}
	}

	return &ManagerImpl{
		path:     path,
		Policies: policies,
		managers: managers,

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Regenerate the policy value with the intended policy builder (e.g. cauthdsl helpers) instead of hand-editing bytes
  2. Validate the policy envelope proto before committing it to channel config
  3. Inspect the wrapped cause (errors.Unwrap) for the underlying compile failure and fix accordingly

Example fix

// before: hand-assembled invalid envelope bytes
Policy{Type: SIGNATURE, Value: badBytes}
// after
env := cauthdsl.SignedByMspMember("Org1MSP")
val, _ := proto.Marshal(env)
Policy{Type: SIGNATURE, Value: val}
Defensive patterns

Strategy: try-catch

Validate before calling

// Compile-check signature policy values before committing
var env cb.SignaturePolicyEnvelope
if err := proto.Unmarshal(p.Value, &env); err != nil {
  return fmt.Errorf("policy value is not a valid envelope: %w", err)
}

Try / catch

mgr, err := policies.NewManagerImpl(root, path, providers)
if err != nil && strings.Contains(err.Error(), "did not compile") {
  cause := errors.Unwrap(err)
  return fmt.Errorf("policy body invalid (%v): regenerate with cauthdsl", cause)
}

Prevention

When it happens

Trigger: Calling NewManagerImpl where a signature-type policy's Value bytes do not unmarshal/compile into a valid SignaturePolicyEnvelope, e.g. corrupted protobuf bytes or an envelope with unresolvable principals.

Common situations: Channel update carried a hand-crafted signature policy envelope that fails validation; policy value bytes truncated or corrupted during config editing; principal references (MSP IDs, roles) invalid for the deployed configuration.

Related errors


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