{"record":{"id":"03aba12359f5dfc6","repo":"hyperledger/fabric","slug":"failing-extracting-header-during-check-policy-on-c","errorCode":null,"errorMessage":"Failing extracting header during check policy on channel [%s] with policy [%s]: [%s]","messagePattern":"Failing extracting header during check policy on channel \\[(.+?)\\] with policy \\[(.+?)\\]: \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/policy/policy.go","lineNumber":88,"sourceCode":"\tif signedProp == nil {\n\t\treturn fmt.Errorf(\"Invalid signed proposal during check policy on channel [%s] with policy [%s]\", channelID, policyName)\n\t}\n\n\t// Get Policy\n\tpolicyManager := p.channelPolicyManagerGetter.Manager(channelID)\n\tif policyManager == nil {\n\t\treturn fmt.Errorf(\"Failed to get policy manager for channel [%s]\", channelID)\n\t}\n\n\t// Prepare SignedData\n\tproposal, err := protoutil.UnmarshalProposal(signedProp.ProposalBytes)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failing extracting proposal during check policy on channel [%s] with policy [%s]: [%s]\", channelID, policyName, err)\n\t}\n\n\theader, err := protoutil.UnmarshalHeader(proposal.Header)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failing extracting header during check policy on channel [%s] with policy [%s]: [%s]\", channelID, policyName, err)\n\t}\n\n\tshdr, err := protoutil.UnmarshalSignatureHeader(header.SignatureHeader)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Invalid Proposal's SignatureHeader during check policy on channel [%s] with policy [%s]: [%s]\", channelID, policyName, err)\n\t}\n\n\tsd := []*protoutil.SignedData{{\n\t\tData:      signedProp.ProposalBytes,\n\t\tIdentity:  shdr.Creator,\n\t\tSignature: signedProp.Signature,\n\t}}\n\n\treturn p.CheckPolicyBySignedData(channelID, policyName, sd)\n}\n\n// CheckPolicyNoChannel checks that the passed signed proposal is valid with the respect to\n// passed policy on the local MSP.","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/policy/policy.go#L70-L106","documentation":"After the Proposal is successfully extracted, CheckPolicy unmarshals proposal.Header with protoutil.UnmarshalHeader. If the Header bytes inside the proposal are invalid (empty or not a serialized Header protobuf), policy evaluation cannot identify the channel/creator and fails with this wrapped error naming the channel, policy, and underlying cause.","triggerScenarios":"A proposal whose Header field is nil, empty, or contains bytes from a different message type; proposals crafted by hand or decoded/re-encoded incorrectly by middleware.","commonSituations":"Custom client code marshaling the wrong struct into proposal.Header; clients built against a different fabric-protos version where Header layout changed; tampered or truncated proposals received through a proxy.","solutions":["Regenerate the proposal with the SDK so Header is populated via protoutil/proposal factory","Check the embedded error text to confirm whether Header bytes are empty or a type mismatch","Align fabric-protos / SDK versions between client and peer","Reject such proposals at the client before submission by validating proposal.Header is set"],"exampleFix":"// before\nprop := &pb.Proposal{ PayloadBytes: payload } // Header never set\n// after\nhdr, _ := protoutil.Marshal(header)\nprop := &pb.Proposal{ Header: hdr, PayloadBytes: payload }","handlingStrategy":"try-catch","validationCode":"// Ensure Header is marshalled into the proposal before sending\nif len(proposal.Header) == 0 {\n    return errors.New(\"proposal.Header must be set\")\n}","typeGuard":"function hasHeaderBytes(p) { return p && p.header && p.header.length > 0; }","tryCatchPattern":"err := checker.CheckPolicy(policyName, signedProp)\nif err != nil {\n    if strings.Contains(err.Error(), \"Failing extracting header\") {\n        // Header bytes malformed: reject or re-request a valid proposal\n    }\n    return err\n}","preventionTips":["Set Header via protoutil helper constructors","Marshal a Header before signing the proposal","Use fabric-protos generated types only","Test proposals round-trip through UnmarshalProposal/UnmarshalHeader"],"tags":["hyperledger-fabric","protobuf","header","policy"],"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-08T10:18:20.063Z"}