hyperledger/fabric · error

invalid consensus type property in config: %v

Error message

invalid consensus type property in config: %v

What it means

The raw bytes of the Orderer group's ConsensusType config value must unmarshal into an orderer.ConsensusType protobuf. If proto.Unmarshal fails, the value is corrupt or was produced by an incompatible writer, so the config update is rejected.

Source

Thrown at orderer/consensus/smartbft/configverifier.go:177

	if conf.ChannelGroup.Groups["Orderer"].Policies["BlockValidation"] == nil {
		return fmt.Errorf("block validation policy is not found in the policies of 'Orderer' group")
	}

	actualPolicy := conf.ChannelGroup.Groups["Orderer"].Policies["BlockValidation"].Policy

	if !proto.Equal(expectedConfigPol, actualPolicy) {
		return fmt.Errorf("block validation policy should be a signature policy: %v but it is %v instead", expectedConfigPol, actualPolicy)
	}

	consensusTypeConfigValue := conf.ChannelGroup.Groups["Orderer"].Values["ConsensusType"]

	if consensusTypeConfigValue == nil {
		return fmt.Errorf("missing consensus type property in config")
	}

	consensusTypeValue := &protosorderer.ConsensusType{}
	if err := proto.Unmarshal(consensusTypeConfigValue.Value, consensusTypeValue); err != nil {
		return fmt.Errorf("invalid consensus type property in config: %v", err)
	}

	configOptions := &smartbft.Options{}
	if err := proto.Unmarshal(consensusTypeValue.Metadata, configOptions); err != nil {
		return fmt.Errorf("invalid options encoded in consensus metadata: %v", err)
	}

	if configOptions.LeaderRotation == smartbft.Options_ROTATION_ON {
		return fmt.Errorf("leader rotation must be turned off for this version or be unspecified")
	}

	return nil
}

func (cbv *ConfigBlockValidator) verifyConfigUpdateMsg(outEnv *common.Envelope, confEnv *common.ConfigEnvelope, chdr *common.ChannelHeader) error {
	if confEnv == nil || confEnv.LastUpdate == nil || confEnv.Config == nil {
		return errors.New("invalid config envelope")
	}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Rebuild the ConsensusType value by marshaling a proper &orderer.ConsensusType{...} with proto.Marshal and correct proto field types
  2. Regenerate the config with the same Fabric version's configtxgen to avoid protobuf incompatibilities
  3. Inspect the value bytes with protoc --decode_raw to see what was actually stored

Example fix

// before
valueBytes, _ := json.Marshal(myConsensusType) // wrong encoding
// after
valueBytes, err := proto.Marshal(&orderer.ConsensusType{Type: "smartbft", Metadata: metadataBytes})
if err != nil { return err }
Defensive patterns

Strategy: validation

Validate before calling

ctv := &orderer.ConsensusType{}
if err := proto.Unmarshal(cfgVal.Value, ctv); err != nil {
    return fmt.Errorf("ConsensusType value bytes are not a valid orderer.ConsensusType: %w", err)
}

Try / catch

defer func() {
    if r := recover(); r != nil { log.Printf("config envelope processing failed: %v", r) }
}()
if err := proto.Unmarshal(value.Value, &orderer.ConsensusType{}); err != nil {
    return fmt.Errorf("rejecting config: %w", err)
}

Prevention

When it happens

Trigger: verifyConfigUpdateMsg -> checkConsentersMatchPolicy when proto.Unmarshal(consensusTypeConfigValue.Value, consensusTypeValue) returns an error, i.e. the value bytes are not a valid orderer.ConsensusType message.

Common situations: Config values written by external tools with wrong field layout; byte-level edits of the channel config binary; mixing protobuf versions or wrong message types when programmatically building config; corruption during manual JSON<->binary conversion of the config.

Understand the failure class

Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.

Related errors


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