{"record":{"id":"e86d835a8b78766c","repo":"hyperledger/fabric","slug":"no-channel-specified","errorCode":null,"errorMessage":"no channel specified","messagePattern":"no channel specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/cmd/config.go","lineNumber":51,"sourceCode":"}\n\n// SetServer sets the server of the ConfigCmd\nfunc (pc *ConfigCmd) SetServer(server *string) {\n\tpc.server = server\n}\n\n// SetChannel sets the channel of the ConfigCmd\nfunc (pc *ConfigCmd) SetChannel(channel *string) {\n\tpc.channel = channel\n}\n\n// Execute executes the command\nfunc (pc *ConfigCmd) Execute(conf common.Config) error {\n\tif pc.server == nil || *pc.server == \"\" {\n\t\treturn errors.New(\"no server specified\")\n\t}\n\tif pc.channel == nil || *pc.channel == \"\" {\n\t\treturn errors.New(\"no channel specified\")\n\t}\n\n\tserver := *pc.server\n\tchannel := *pc.channel\n\n\treq := discovery.NewRequest().OfChannel(channel).AddConfigQuery()\n\tres, err := pc.stub.Send(server, conf, req)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn pc.parser.ParseResponse(channel, res)\n}\n\n// ConfigResponseParser parses config responses\ntype ConfigResponseParser struct {\n\tio.Writer\n}\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/cmd/config.go#L33-L69","documentation":"ConfigCmd.Execute requires a channel name to build a channel-scoped discovery config query (NewRequest().OfChannel(channel)). If the --channel flag is nil or empty, there is no channel to query, so the command returns this error before contacting the server.","triggerScenarios":"Running the discovery config command without --channel, or calling ConfigCmd.Execute without invoking SetChannel.","commonSituations":"Forgot --channel (or -C) flag on the CLI; channel name sourced from an unset env var or empty config value; scripts templated without the channel substituted.","solutions":["Pass --channel <channel-name> to the discovery config command","Call configCmd.SetChannel(\"mychannel\") before Execute when using the library API","Check that the environment/config value feeding the channel name is non-empty"],"exampleFix":"// before\nconfigCmd := discovery.NewConfigCmd()\nconfigCmd.SetServer(\"peer0:7051\")\n// after\nconfigCmd := discovery.NewConfigCmd()\nconfigCmd.SetServer(\"peer0:7051\")\nconfigCmd.SetChannel(\"mychannel\")","handlingStrategy":"validation","validationCode":"if channel == \"\" {\n    return errors.New(\"--channel is required for the discovery config command\")\n}","typeGuard":"func hasChannel(pc *discovery.ConfigCmd) bool {\n    return pc.Channel != nil && *pc.Channel != \"\"\n}","tryCatchPattern":"if err := configCmd.Execute(conf); err != nil {\n    if strings.Contains(err.Error(), \"no channel specified\") {\n        return fmt.Errorf(\"supply --channel <name>: %w\", err)\n    }\n    return err\n}","preventionTips":["Set a default channel via env (e.g. CORE_CHANNEL) in deployment scripts","Validate channel names exist before running discovery queries","Keep channel and server flags paired in all discovery commands"],"tags":["go","cli","discovery","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}