{"record":{"id":"1a32df583a97a99c","repo":"hyperledger/fabric","slug":"invalid-consensus-type-property-in-config-v","errorCode":null,"errorMessage":"invalid consensus type property in config: %v","messagePattern":"invalid consensus type property in config: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/consensus/smartbft/configverifier.go","lineNumber":177,"sourceCode":"\tif conf.ChannelGroup.Groups[\"Orderer\"].Policies[\"BlockValidation\"] == nil {\n\t\treturn fmt.Errorf(\"block validation policy is not found in the policies of 'Orderer' group\")\n\t}\n\n\tactualPolicy := conf.ChannelGroup.Groups[\"Orderer\"].Policies[\"BlockValidation\"].Policy\n\n\tif !proto.Equal(expectedConfigPol, actualPolicy) {\n\t\treturn fmt.Errorf(\"block validation policy should be a signature policy: %v but it is %v instead\", expectedConfigPol, actualPolicy)\n\t}\n\n\tconsensusTypeConfigValue := conf.ChannelGroup.Groups[\"Orderer\"].Values[\"ConsensusType\"]\n\n\tif consensusTypeConfigValue == nil {\n\t\treturn fmt.Errorf(\"missing consensus type property in config\")\n\t}\n\n\tconsensusTypeValue := &protosorderer.ConsensusType{}\n\tif err := proto.Unmarshal(consensusTypeConfigValue.Value, consensusTypeValue); err != nil {\n\t\treturn fmt.Errorf(\"invalid consensus type property in config: %v\", err)\n\t}\n\n\tconfigOptions := &smartbft.Options{}\n\tif err := proto.Unmarshal(consensusTypeValue.Metadata, configOptions); err != nil {\n\t\treturn fmt.Errorf(\"invalid options encoded in consensus metadata: %v\", err)\n\t}\n\n\tif configOptions.LeaderRotation == smartbft.Options_ROTATION_ON {\n\t\treturn fmt.Errorf(\"leader rotation must be turned off for this version or be unspecified\")\n\t}\n\n\treturn nil\n}\n\nfunc (cbv *ConfigBlockValidator) verifyConfigUpdateMsg(outEnv *common.Envelope, confEnv *common.ConfigEnvelope, chdr *common.ChannelHeader) error {\n\tif confEnv == nil || confEnv.LastUpdate == nil || confEnv.Config == nil {\n\t\treturn errors.New(\"invalid config envelope\")\n\t}","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/consensus/smartbft/configverifier.go#L159-L195","documentation":"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.","triggerScenarios":"verifyConfigUpdateMsg -> checkConsentersMatchPolicy when proto.Unmarshal(consensusTypeConfigValue.Value, consensusTypeValue) returns an error, i.e. the value bytes are not a valid orderer.ConsensusType message.","commonSituations":"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.","solutions":["Rebuild the ConsensusType value by marshaling a proper &orderer.ConsensusType{...} with proto.Marshal and correct proto field types","Regenerate the config with the same Fabric version's configtxgen to avoid protobuf incompatibilities","Inspect the value bytes with protoc --decode_raw to see what was actually stored"],"exampleFix":"// before\nvalueBytes, _ := json.Marshal(myConsensusType) // wrong encoding\n// after\nvalueBytes, err := proto.Marshal(&orderer.ConsensusType{Type: \"smartbft\", Metadata: metadataBytes})\nif err != nil { return err }","handlingStrategy":"validation","validationCode":"ctv := &orderer.ConsensusType{}\nif err := proto.Unmarshal(cfgVal.Value, ctv); err != nil {\n    return fmt.Errorf(\"ConsensusType value bytes are not a valid orderer.ConsensusType: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil { log.Printf(\"config envelope processing failed: %v\", r) }\n}()\nif err := proto.Unmarshal(value.Value, &orderer.ConsensusType{}); err != nil {\n    return fmt.Errorf(\"rejecting config: %w\", err)\n}","preventionTips":["Marshal all config values with proto.Marshal of the exact message type","Avoid JSON/manual encodings of protobuf config values","Pin Fabric/protobuf versions across tools that write channel config"],"tags":["hyperledger-fabric","smartbft","protobuf","config-validation"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}