{"record":{"id":"98a33ff4ec065565","repo":"hyperledger/fabric","slug":"invalid-header-type-s","errorCode":null,"errorMessage":"invalid header type %s","messagePattern":"invalid header type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/common/validation/msgvalidation.go","lineNumber":99,"sourceCode":"\t}\n\n\treturn nil\n}\n\n// checks for a valid ChannelHeader\nfunc validateChannelHeader(cHdr *common.ChannelHeader) error {\n\t// check for nil argument\n\tif cHdr == nil {\n\t\treturn errors.New(\"nil ChannelHeader provided\")\n\t}\n\n\t// validate the header type\n\tswitch common.HeaderType(cHdr.Type) {\n\tcase common.HeaderType_ENDORSER_TRANSACTION:\n\tcase common.HeaderType_CONFIG_UPDATE:\n\tcase common.HeaderType_CONFIG:\n\tdefault:\n\t\treturn errors.Errorf(\"invalid header type %s\", common.HeaderType(cHdr.Type))\n\t}\n\n\tputilsLogger.Debugf(\"validateChannelHeader info: header type %d\", common.HeaderType(cHdr.Type))\n\n\t// TODO: validate channelID in cHdr.ChannelID\n\n\t// Validate epoch in cHdr.Epoch\n\t// Currently we enforce that Epoch is 0.\n\t// TODO: This check will be modified once the Epoch management\n\t// will be in place.\n\tif cHdr.Epoch != 0 {\n\t\treturn errors.Errorf(\"invalid Epoch in ChannelHeader. Expected 0, got [%d]\", cHdr.Epoch)\n\t}\n\n\t// TODO: Validate version in cHdr.Version\n\n\treturn nil\n}","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/common/validation/msgvalidation.go#L81-L117","documentation":"validateChannelHeader only accepts ChannelHeader types ENDORSER_TRANSACTION, CONFIG_UPDATE, and CONFIG. Any other HeaderType (e.g. MESSAGE, DELIVER_SEEK_INFO, PEER_RESOURCE_UPDATE) reaches the default case and is rejected with this formatted error including the type's string name.","triggerScenarios":"Submitting or validating a payload whose ChannelHeader.Type is not one of the three accepted values — e.g. a client sending a HeaderType_MESSAGE envelope through ValidateTransaction, or a mislabeled header type constant.","commonSituations":"Clients reusing envelope-construction code with the wrong header type constant; internal messages (like deliver/seek requests) mistakenly routed through transaction validation; numeric type fields set by hand with wrong enum values; Fabric version changes adding new header types not accepted here.","solutions":["Set ChannelHeader.Type to common.HeaderType_ENDORSER_TRANSACTION for regular transaction submissions","Use CONFIG or CONFIG_UPDATE only through the config-update path (configtxgen / channel update flow)","Check the numeric/enum value in the client SDK maps to a valid Fabric HeaderType","Verify you are routing deliver/seek or other internal messages through the correct service, not transaction validation"],"exampleFix":"// before\nchdr := protoutil.MakeChannelHeader(common.HeaderType_MESSAGE, 0, channelID, txid)\n// after\nchdr := protoutil.MakeChannelHeader(common.HeaderType_ENDORSER_TRANSACTION, 0, channelID, txid)","handlingStrategy":"validation","validationCode":"func headerTypeAllowed(t common.HeaderType) bool {\n    switch t {\n    case common.HeaderType_ENDORSER_TRANSACTION, common.HeaderType_CONFIG, common.HeaderType_CONFIG_UPDATE:\n        return true\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.HasPrefix(err.Error(), \"invalid header type\") {\n    // set the correct HeaderType constant and rebuild the envelope\n}","preventionTips":["Use the common.HeaderType_* constants, never raw ints, for header types","Route non-transaction messages (seek/deliver) through their own services","Pin SDK versions whose HeaderType enum matches the Fabric core version in use"],"tags":["hyperledger-fabric","validation","header-type","transaction"],"backgroundTag":"invalid-header-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"}