hyperledger/fabric · error

This evaluator only understands messages of version 0, but v

Error message

This evaluator only understands messages of version 0, but version was %d

What it means

Guard in EnvelopeBasedPolicyProvider/evaluator: the SignaturePolicyEnvelope carried a Version other than 0, the only policy version this evaluator understands, so the policy bytes are from an incompatible schema.

Source

Thrown at common/cauthdsl/policy.go:39

	deserializer msp.IdentityDeserializer
}

// NewPolicyProvider provides a policy generator for cauthdsl type policies
func NewPolicyProvider(deserializer msp.IdentityDeserializer) policies.Provider {
	return &provider{
		deserializer: deserializer,
	}
}

// NewPolicy creates a new policy based on the policy bytes
func (pr *provider) NewPolicy(data []byte) (policies.Policy, proto.Message, error) {
	sigPolicy := &cb.SignaturePolicyEnvelope{}
	if err := proto.Unmarshal(data, sigPolicy); err != nil {
		return nil, nil, fmt.Errorf("Error unmarshalling to SignaturePolicy: %s", err)
	}

	if sigPolicy.Version != 0 {
		return nil, nil, fmt.Errorf("This evaluator only understands messages of version 0, but version was %d", sigPolicy.Version)
	}

	compiled, err := compile(sigPolicy.Rule, sigPolicy.Identities)
	if err != nil {
		return nil, nil, err
	}

	return &policy{
		evaluator:               compiled,
		deserializer:            pr.deserializer,
		signaturePolicyEnvelope: sigPolicy,
	}, sigPolicy, nil
}

// EnvelopeBasedPolicyProvider allows to create a new policy from SignaturePolicyEnvelope struct instead of []byte
type EnvelopeBasedPolicyProvider struct {
	Deserializer msp.IdentityDeserializer
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Set the envelope Version to 0 before serializing, or regenerate with compatible tooling
  2. Align the evaluator (library) and producer (tooling) on the same Fabric version
  3. Validate sigPolicy.Version == 0 in policy-generation code before persisting

Example fix

// before
env := &cb.SignaturePolicyEnvelope{Version: 1, Rule: rule, Identities: ids}
// after
env := &cb.SignaturePolicyEnvelope{Version: 0, Rule: rule, Identities: ids}
Defensive patterns

Strategy: validation

Validate before calling

if env.Version != 0 {
    return fmt.Errorf("unsupported SignaturePolicyEnvelope version %d; only 0 accepted", env.Version)
}

Type guard

func isV0Envelope(env *cb.SignaturePolicyEnvelope) bool { return env != nil && env.Version == 0 }

Try / catch

policy, _, err := provider.NewPolicy(data)
if err != nil && strings.Contains(err.Error(), "version 0") {
    return fmt.Errorf("policy produced by incompatible Fabric version: %w", err)
}

Prevention

When it happens

Trigger: Calling NewPolicy (via NewManagerImpl) with a valid SignaturePolicyEnvelope whose Version field was serialized as nonzero — typically written by a newer schema/tooling that bumped Version.

Common situations: Policy generated by a Fabric tool version ahead of the running evaluator; hand-edited proto where Version defaulted incorrectly after a copy; schema evolution experiments.

Related errors


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