{"record":{"id":"31174dd37d4bcf67","repo":"hyperledger/fabric","slug":"bad-configuration-envelope-s","errorCode":null,"errorMessage":"Bad configuration envelope: %s","messagePattern":"Bad configuration envelope: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scc/cscc/configure.go","lineNumber":225,"sourceCode":"\t\t}\n\n\t\treturn e.getChannels()\n\n\t}\n\treturn shim.Error(fmt.Sprintf(\"Requested function %s not found.\", fname))\n}\n\n// validateConfigBlock validate configuration block to see whenever it's contains valid config transaction\nfunc validateConfigBlock(block *common.Block, bccsp bccsp.BCCSP) error {\n\tenvelopeConfig, err := protoutil.ExtractEnvelope(block, 0)\n\tif err != nil {\n\t\treturn errors.Errorf(\"Failed to %s\", err)\n\t}\n\n\tconfigEnv := &common.ConfigEnvelope{}\n\t_, err = protoutil.UnmarshalEnvelopeOfType(envelopeConfig, common.HeaderType_CONFIG, configEnv)\n\tif err != nil {\n\t\treturn errors.Errorf(\"Bad configuration envelope: %s\", err)\n\t}\n\n\tif configEnv.Config == nil {\n\t\treturn errors.New(\"Nil config envelope Config\")\n\t}\n\n\tif configEnv.Config.ChannelGroup == nil {\n\t\treturn errors.New(\"Nil channel group\")\n\t}\n\n\tif configEnv.Config.ChannelGroup.Groups == nil {\n\t\treturn errors.New(\"No channel configuration groups are available\")\n\t}\n\n\t_, exists := configEnv.Config.ChannelGroup.Groups[channelconfig.ApplicationGroupKey]\n\tif !exists {\n\t\treturn errors.Errorf(\"Invalid configuration block, missing %s \"+\n\t\t\t\"configuration group\", channelconfig.ApplicationGroupKey)","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/scc/cscc/configure.go#L207-L243","documentation":"This error is thrown by cscc (the system chaincode that handles channel creation/joining) in validateConfigBlock when protoutil.UnmarshalEnvelopeOfType cannot decode the submitted config transaction envelope as a common.HeaderType_CONFIG envelope. It means the envelope submitted to JoinChain was not a marshaled ConfigEnvelope (e.g. it is a different header type, malformed protobuf bytes, or wrapped incorrectly). The %s carries the underlying unmarshal error.","triggerScenarios":"Calling cscc.Invoke (JoinChain) with an envelope whose payload is not a marshaled ConfigEnvelope; submitting the genesis/config envelope for the wrong header type (e.g. HeaderType_MESSAGE or HeaderType_ENDORSER_TRANSACTION); passing corrupted or truncated envelope bytes; wrapping the ConfigEnvelope in an extra serialization layer before signing.","commonSituations":"Fabric SDK channel-creation flows where the user concatenates or re-marshals envelopes incorrectly; custom tooling that builds config transactions by hand; upgrading Fabric versions where the config envelope schema changed; submitting an update envelope (HeaderType_CONFIG_UPDATE) where a fully-applied config envelope was expected.","solutions":["Regenerate the config envelope using the standard path: cryptogen/configtxgen to produce a genesis block, or `configtxlator proto_encode --type common.ConfigEnvelope` for updates","Ensure the envelope passed to JoinChain is the full ConfigEnvelope (not a ConfigUpdateEnvelope) marshaled into a HeaderType_CONFIG envelope","Verify the envelope bytes are not corrupted in transit (compare sha256 of the marshaled envelope on both sides)","Check that protoutil.CreateSignedEnvelope with common.HeaderType_CONFIG was used and signatures applied with the right MSP identities"],"exampleFix":"// before: raw ConfigEnvelope passed to JoinChain\nenv := &common.ConfigEnvelope{Config: cfg}\npayload, _ := proto.Marshal(env)\n// after: wrap in an envelope of HeaderType_CONFIG\nenvBytes, _ := proto.Marshal(env)\nenv2, _ := protoutil.CreateSignedEnvelope(common.HeaderType_CONFIG, chID, signer, &common.ConfigEnvelope{}, 0, 0)","handlingStrategy":"validation","validationCode":"env, err := protoutil.UnmarshalEnvelopeOfType(envelopeConfig, common.HeaderType_CONFIG, &common.ConfigEnvelope{})\nif err != nil { return fmt.Errorf(\"config envelope not decodable: %w\", err) }","typeGuard":"func isConfigEnvelope(env *common.Envelope) bool {\n    p := &common.Payload{}\n    if protoutil.Unmarshal(env.Payload, p) != nil { return false }\n    return p.Header != nil && p.Header.ChannelHeader != nil &&\n        common.HeaderType(p.Header.ChannelHeader.Type) == common.HeaderType_CONFIG\n}","tryCatchPattern":"if err != nil {\n    var ce *common.ConfigEnvelope\n    if _, uerr := protoutil.UnmarshalEnvelopeOfType(envelopeConfig, common.HeaderType_CONFIG, ce); uerr != nil {\n        return fmt.Errorf(\"submit a valid HeaderType_CONFIG envelope: %w\", uerr)\n    }\n}","preventionTips":["Always build envelopes with protoutil.CreateSignedEnvelope(common.HeaderType_CONFIG, ...) rather than hand-marshaling","Generate genesis blocks with configtxgen instead of crafting config envelopes manually","Verify envelope bytes with protoutil.UnmarshalEnvelopeOfType in tests before submission","Never re-encode an envelope after signing"],"tags":["fabric","system-chaincode","protobuf","config-envelope"],"backgroundTag":"malformed-config-envelope","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"}