{"record":{"id":"392e558313d147fe","repo":"hyperledger/fabric","slug":"error-unmarshalling-configenvelope","errorCode":null,"errorMessage":"error unmarshalling ConfigEnvelope","messagePattern":"error unmarshalling ConfigEnvelope","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/unmarshalers.go","lineNumber":102,"sourceCode":"\nfunc UnmarshalSerializedIdentity(bytes []byte) (*msp.SerializedIdentity, error) {\n\tsid := &msp.SerializedIdentity{}\n\terr := proto.Unmarshal(bytes, sid)\n\treturn sid, errors.Wrap(err, \"error unmarshalling SerializedIdentity\")\n}\n\n// UnmarshalHeader unmarshals bytes to a Header\nfunc UnmarshalHeader(bytes []byte) (*common.Header, error) {\n\thdr := &common.Header{}\n\terr := proto.Unmarshal(bytes, hdr)\n\treturn hdr, errors.Wrap(err, \"error unmarshalling Header\")\n}\n\n// UnmarshalConfigEnvelope unmarshals bytes to a ConfigEnvelope\nfunc UnmarshalConfigEnvelope(bytes []byte) (*common.ConfigEnvelope, error) {\n\tcfg := &common.ConfigEnvelope{}\n\terr := proto.Unmarshal(bytes, cfg)\n\treturn cfg, errors.Wrap(err, \"error unmarshalling ConfigEnvelope\")\n}\n\n// UnmarshalChaincodeHeaderExtension unmarshals bytes to a ChaincodeHeaderExtension\nfunc UnmarshalChaincodeHeaderExtension(hdrExtension []byte) (*peer.ChaincodeHeaderExtension, error) {\n\tchaincodeHdrExt := &peer.ChaincodeHeaderExtension{}\n\terr := proto.Unmarshal(hdrExtension, chaincodeHdrExt)\n\treturn chaincodeHdrExt, errors.Wrap(err, \"error unmarshalling ChaincodeHeaderExtension\")\n}\n\n// UnmarshalProposalResponse unmarshals bytes to a ProposalResponse\nfunc UnmarshalProposalResponse(prBytes []byte) (*peer.ProposalResponse, error) {\n\tproposalResponse := &peer.ProposalResponse{}\n\terr := proto.Unmarshal(prBytes, proposalResponse)\n\treturn proposalResponse, errors.Wrap(err, \"error unmarshalling ProposalResponse\")\n}\n\n// UnmarshalChaincodeAction unmarshals bytes to a ChaincodeAction\nfunc UnmarshalChaincodeAction(caBytes []byte) (*peer.ChaincodeAction, error) {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/unmarshalers.go#L84-L120","documentation":"Returned by protoutil.UnmarshalConfigEnvelope when proto.Unmarshal fails to decode bytes into a common.ConfigEnvelope. The wrapper adds the message-type context to the raw protobuf error. It signals the configuration bytes are invalid, of the wrong type, or corrupted.","triggerScenarios":"Calling UnmarshalConfigEnvelope on block data/payload bytes that are not a ConfigEnvelope (e.g. an ordinary transaction payload), empty bytes, truncated config updates, or config generated by an incompatible Fabric version; used in addNodeToConfig/removeNodeFromConfig flows.","commonSituations":"Processing config blocks and extracting the envelope from the wrong payload field; passing config update JSON/YAML bytes instead of the marshaled protobuf; channel creation tooling version mismatch.","solutions":["Ensure you pass payload.Data of a CONFIG-type envelope, not an ENDORSER_TRANSACTION payload.","Verify the bytes were produced by marshaling a common.ConfigEnvelope (e.g. via configtxgen output), not raw JSON/YAML.","Check the block type in the channel header before attempting to unmarshal.","Align Fabric tooling (configtxgen, SDK) versions with the orderer.","Log length and hex prefix of failing bytes to detect truncation/corruption."],"exampleFix":"// before\ncfg, _ := protoutil.UnmarshalConfigEnvelope(block.Data)\n// after\nenv, _ := protoutil.UnmarshalEnvelope(block.Data)\npayload, _ := protoutil.UnmarshalPayload(env.Payload)\ncfg, err := protoutil.UnmarshalConfigEnvelope(payload.Data)\nif err != nil {\n    return fmt.Errorf(\"not a config envelope: %w\", err)\n}","handlingStrategy":"validation","validationCode":"func isConfigBlock(chdr *common.ChannelHeader) bool {\n    return chdr.Type == int32(common.HeaderType_CONFIG)\n}","typeGuard":"func isConfigEnvelope(v any) bool {\n    _, ok := v.(*common.ConfigEnvelope)\n    return ok\n}","tryCatchPattern":"cfg, err := protoutil.UnmarshalConfigEnvelope(payload.Data)\nif err != nil {\n    return fmt.Errorf(\"payload is not a config envelope: %w\", err)\n}","preventionTips":["Check the channel header type is CONFIG before unmarshaling","Unmarshal Envelope and Payload first to reach payload.Data correctly","Pass marshaled protobuf, never JSON/YAML config files","Regenerate config with a matching configtxgen version"],"tags":["fabric","protobuf","unmarshal","config","channel"],"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"}