{"record":{"id":"573db5315da35521","repo":"hyperledger/fabric","slug":"key-config-channelgroup-groups-s-groups-is-nil","errorCode":null,"errorMessage":"key Config.ChannelGroup.Groups[%s].Groups is nil","messagePattern":"key Config\\.ChannelGroup\\.Groups\\[(.+?)\\]\\.Groups is nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/support/config/support.go","lineNumber":242,"sourceCode":"\n\treturn nil\n}\n\nfunc ValidateConfig(c *common.Config) error {\n\tif c.ChannelGroup == nil {\n\t\treturn errors.New(\"field Config.ChannelGroup is nil\")\n\t}\n\tgrps := c.ChannelGroup.Groups\n\tif grps == nil {\n\t\treturn errors.New(\"field Config.ChannelGroup.Groups is nil\")\n\t}\n\tfor _, field := range []string{channelconfig.OrdererGroupKey, channelconfig.ApplicationGroupKey} {\n\t\tgrp, exists := grps[field]\n\t\tif !exists {\n\t\t\treturn fmt.Errorf(\"key Config.ChannelGroup.Groups[%s] is missing\", field)\n\t\t}\n\t\tif grp.Groups == nil {\n\t\t\treturn fmt.Errorf(\"key Config.ChannelGroup.Groups[%s].Groups is nil\", field)\n\t\t}\n\t}\n\tif c.ChannelGroup.Values == nil {\n\t\treturn errors.New(\"field Config.ChannelGroup.Values is nil\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":224,"sourceCodeEnd":250,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/support/config/support.go#L224-L250","documentation":"This error comes from Hyperledger Fabric's discovery service config validation (ValidateConfig in discovery/support/config/support.go). When building a channel config from a protobuf Config, the code iterates over the Orderer and Application group keys and requires each ConfigGroup to exist AND to have a non-nil sub-Groups map. A nil Groups map means the channel config was built without proper Orderer/Application sub-groups, so discovery cannot parse the channel hierarchy.","triggerScenarios":"Calling ValidateConfig (directly or via NewConfig support construction) with a *common.Config whose ChannelGroup.Groups[\"Orderer\"] or ChannelGroup.Groups[\"Application\"] exists but has Groups == nil — e.g. a config created programmatically that sets the group value but never initializes its nested Groups map, or a config decoded from truncated/malformed channel config bytes.","commonSituations":"Building channel config protobufs by hand for unit tests or tooling; passing a partial Config (e.g. only Consortiums or only the root group populated) into the discovery support; upgrading Fabric versions and feeding legacy config blobs that lack Orderer/Application sub-groups.","solutions":["Ensure the Config is produced by the standard channel config toolchain (configtxgen / channel config update flow) so Orderer and Application groups each contain a populated Groups map","If constructing common.Config manually, initialize grp.Groups = map[string]*common.ConfigGroup{} (with required sub-groups) instead of leaving it nil","Validate the serialized channel config block with configtxlator before feeding it to the discovery support"],"exampleFix":"// before\ngrp, _ := cfg.ChannelGroup.Groups[channelconfig.ApplicationGroupKey]\ngrp.Values = ...\n// Groups left nil\n\n// after\ngrp, _ := cfg.ChannelGroup.Groups[channelconfig.ApplicationGroupKey]\nif grp.Groups == nil {\n    grp.Groups = make(map[string]*common.ConfigGroup)\n}\ngrp.Groups[\"MyOrg\"] = &common.ConfigGroup{Groups: map[string]*common.ConfigGroup{}, ...}","handlingStrategy":"validation","validationCode":"func hasGroups(cfg *common.Config) bool {\n    if cfg == nil || cfg.ChannelGroup == nil || cfg.ChannelGroup.Groups == nil {\n        return false\n    }\n    for _, k := range []string{\"Orderer\", \"Application\"} {\n        g, ok := cfg.ChannelGroup.Groups[k]\n        if !ok || g == nil || g.Groups == nil {\n            return false\n        }\n    }\n    return true\n}\n// if !hasGroups(cfg) { fix config before ValidateConfig }","typeGuard":"func grp, ok := cfg.ChannelGroup.Groups[\"Orderer\"]; ok && grp != nil && grp.Groups != nil; grp","tryCatchPattern":null,"preventionTips":["Always generate channel configs via configtxgen instead of hand-assembling protobufs","Run configtxlator decode/validate on configs before use","When building ConfigGroup literals, always initialize the Groups map"],"tags":["hyperledger-fabric","config-validation","protobuf","discovery"],"backgroundTag":"invalid-channel-config","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"}