{"record":{"id":"29555c9d3da05555","repo":"hyperledger/fabric","slug":"missing-header","errorCode":null,"errorMessage":"Missing Header","messagePattern":"Missing Header","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/signeddata.go","lineNumber":73,"sourceCode":"\n\treturn result, nil\n}\n\n// EnvelopeAsSignedData returns the signatures for the Envelope as SignedData\n// slice of length 1 or an error indicating why this was not possible.\nfunc EnvelopeAsSignedData(env *common.Envelope) ([]*SignedData, error) {\n\tif env == nil {\n\t\treturn nil, errors.New(\"No signatures for nil Envelope\")\n\t}\n\n\tpayload := &common.Payload{}\n\terr := proto.Unmarshal(env.Payload, payload)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif payload.Header == nil /* || payload.Header.SignatureHeader == nil */ {\n\t\treturn nil, errors.New(\"Missing Header\")\n\t}\n\n\tshdr := &common.SignatureHeader{}\n\terr = proto.Unmarshal(payload.Header.SignatureHeader, shdr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"GetSignatureHeaderFromBytes failed, err %s\", err)\n\t}\n\n\treturn []*SignedData{{\n\t\tData:      env.Payload,\n\t\tIdentity:  shdr.Creator,\n\t\tSignature: env.Signature,\n\t}}, nil\n}\n\n// LogMessageForSerializedIdentity returns a string with serialized identity information,\n// or a string indicating why the serialized identity information cannot be returned.\n// Any errors are intentionally returned in the return strings so that the function can be used in single-line log messages with minimal clutter.","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/signeddata.go#L55-L91","documentation":"EnvelopeAsSignedData requires the envelope's Payload to carry a Header, because the creator identity needed for SignedData lives in Payload.Header.SignatureHeader. If payload.Header is nil, there is no way to attribute the signature to an identity, so this error is returned.","triggerScenarios":"An Envelope whose marshaled Payload has no Header — envelopes built by setting only Payload.Data and Signature, payloads that never went through a proposal/transaction constructor, or wire-corrupted payloads that unmarshal without a header.","commonSituations":"Clients submitting raw envelopes without channel/signature headers; tests crafting envelopes by hand; envelopes crossing fabric versions where header fields were dropped; block data hand-modified for tooling.","solutions":["Build envelopes via protoutil.CreateSignedEnvelope (or the SDK's transaction builder) so Payload.Header with ChannelHeader and SignatureHeader is always set.","Validate payload.Header != nil on the client side before signing and submitting.","If the envelope came from a block, treat it as malformed: the transaction will be filtered/rejected by validation anyway.","Ensure the SDK populates SignatureHeader (nonce + creator) — a missing creator means the signature cannot be verified."],"exampleFix":"// before\npayload := &common.Payload{Data: data}\nenv := &common.Envelope{Payload: protoutil.MarshalOrPanic(payload)}\n\n// after\nchdr := protoutil.MakeChannelHeader(common.HeaderType_MESSAGE, msgVersion, chID, epoch)\nshdr := protoutil.MakeSignatureHeader(serializedCreator, nonce)\npayload := &common.Payload{Header: protoutil.MakePayloadHeader(chdr, shdr), Data: data}\nenv, err := protoutil.CreateSignedEnvelope(...)","handlingStrategy":"validation","validationCode":"payload := &common.Payload{}\nif err := proto.Unmarshal(env.Payload, payload); err != nil {\n    return err\n}\nif payload.Header == nil || len(payload.Header.SignatureHeader) == 0 {\n    return errors.New(\"envelope payload must include ChannelHeader and SignatureHeader\")\n}","typeGuard":"func hasPayloadHeader(env *common.Envelope) bool {\n    var p common.Payload\n    if proto.Unmarshal(env.GetPayload(), &p) != nil {\n        return false\n    }\n    return p.Header != nil && len(p.Header.SignatureHeader) > 0 && len(p.Header.ChannelHeader) > 0\n}","tryCatchPattern":"sd, err := protoutil.EnvelopeAsSignedData(env)\nif err != nil {\n    if strings.Contains(err.Error(), \"Missing Header\") {\n        return status.Error(codes.InvalidArgument, \"envelope lacks payload header; rebuild with CreateSignedEnvelope\")\n    }\n    return err\n}","preventionTips":["Always create envelopes via protoutil.CreateSignedEnvelope / CreateSignedEnvelopeWithTLSBinding.","Never assemble Payload with only Data — Header is mandatory for signatures.","Validate headers before submitting to orderers/peers.","Flag raw hand-built envelopes in tests as suspect; prefer SDK transaction builders."],"tags":["fabric","envelope","header","malformed-payload"],"backgroundTag":"missing-payload-header","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"}