{"record":{"id":"2aae4e6de1058e64","repo":"hyperledger/fabric","slug":"tx-type-s-is-not-expected","errorCode":null,"errorMessage":"tx type [%s] is not expected","messagePattern":"tx type \\[(.+?)\\] is not expected","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/peer/configtx_processor.go","lineNumber":42,"sourceCode":"// ConfigTxProcessor implements the interface 'github.com/hyperledger/fabric/core/ledger/customtx/Processor'\ntype ConfigTxProcessor struct{}\n\n// GenerateSimulationResults implements function in the interface 'github.com/hyperledger/fabric/core/ledger/customtx/Processor'\n// This implementation processes CONFIG transactions which simply stores the config-envelope-bytes\nfunc (tp *ConfigTxProcessor) GenerateSimulationResults(txEnv *common.Envelope, simulator ledger.TxSimulator, initializingLedger bool) error {\n\tpayload := protoutil.UnmarshalPayloadOrPanic(txEnv.Payload)\n\tchannelHdr := protoutil.UnmarshalChannelHeaderOrPanic(payload.Header.ChannelHeader)\n\ttxType := common.HeaderType(channelHdr.GetType())\n\n\tswitch txType {\n\tcase common.HeaderType_CONFIG:\n\t\tpeerLogger.Debugf(\"Processing CONFIG\")\n\t\tif payload.Data == nil {\n\t\t\treturn errors.New(\"channel config found nil\")\n\t\t}\n\t\treturn simulator.SetState(peerNamespace, channelConfigKey, payload.Data)\n\tdefault:\n\t\treturn fmt.Errorf(\"tx type [%s] is not expected\", txType)\n\t}\n}\n\nfunc retrieveChannelConfig(queryExecuter ledger.QueryExecutor) (*common.Config, error) {\n\tconfigBytes, err := queryExecuter.GetState(peerNamespace, channelConfigKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif configBytes == nil {\n\t\treturn nil, nil\n\t}\n\tconfigEnvelope := &common.ConfigEnvelope{}\n\tif err := proto.Unmarshal(configBytes, configEnvelope); err != nil {\n\t\treturn nil, err\n\t}\n\treturn configEnvelope.Config, nil\n}\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/peer/configtx_processor.go#L24-L60","documentation":"GenerateSimulationResults only handles HeaderType_CONFIG transactions for the peer's channel-config simulation. Any other transaction type falling into the default branch produces this formatted error identifying the unexpected type.","triggerScenarios":"Calling GenerateSimulationResults with a payload whose header type is not CONFIG (e.g., ENDORSER_TRANSACTION, CONFIG_UPDATE) — the processor is only meant for channel-config simulation.","commonSituations":"Reusing the configtx simulation processor on regular endorsement transactions by mistake; wiring a generic block/payload stream into the config processor; tests feeding arbitrary tx types.","solutions":["Route only HeaderType_CONFIG payloads to GenerateSimulationResults; dispatch other types to their own processors.","Inspect common.HeaderType(hdr.Type) upstream and skip/filter non-CONFIG txs.","If you intended to simulate normal txs, use the appropriate tx validator/simulator path, not the config processor."],"exampleFix":"// before\nsim.GenerateSimulationResults(anyPayload) // any tx type\n// after\nif common.HeaderType(channelHdr.GetType()) == common.HeaderType_CONFIG {\n  sim.GenerateSimulationResults(anyPayload)\n} else {\n  // handle via default endorser tx path\n}","handlingStrategy":"type-guard","validationCode":"if common.HeaderType(payload.Header.ChannelHeader.Type) != common.HeaderType_CONFIG {\n  return errors.New(\"only CONFIG txs accepted here\")\n}","typeGuard":"func isConfigTx(hdr *common.ChannelHeader) bool {\n  return hdr != nil && common.HeaderType(hdr.Type) == common.HeaderType_CONFIG\n}","tryCatchPattern":"if err := sim.GenerateSimulationResults(payload); err != nil && strings.Contains(err.Error(), \"is not expected\") {\n  log.Printf(\"wrong tx type routed to config processor: %v\", err)\n}","preventionTips":["Dispatch payloads by header type","Separate config simulation from endorsement tx processing","Test both branches of the type switch"],"tags":["ledger","config","tx-type","hyperledger-fabric"],"backgroundTag":"unexpected-tx-type","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}