{"record":{"id":"85c57728a28513df","repo":"hyperledger/fabric","slug":"no-channel-specified-85c577","errorCode":null,"errorMessage":"no channel specified","messagePattern":"no channel specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/cmd/endorsers.go","lineNumber":75,"sourceCode":"// SetChaincodes sets the chaincodes to be the given chaincodes\nfunc (pc *EndorsersCmd) SetChaincodes(chaincodes *[]string) {\n\tpc.chaincodes = chaincodes\n}\n\n// SetServer sets the server\nfunc (pc *EndorsersCmd) SetServer(server *string) {\n\tpc.server = server\n}\n\n// SetChannel sets the channel\nfunc (pc *EndorsersCmd) SetChannel(channel *string) {\n\tpc.channel = channel\n}\n\n// Execute executes the command\nfunc (pc *EndorsersCmd) Execute(conf common.Config) error {\n\tif pc.channel == nil || *pc.channel == \"\" {\n\t\treturn errors.New(\"no channel specified\")\n\t}\n\n\tif pc.server == nil || *pc.server == \"\" {\n\t\treturn errors.New(\"no server specified\")\n\t}\n\n\tserver := *pc.server\n\tchannel := *pc.channel\n\n\tccAndCol := &chaincodesAndCollections{\n\t\tChaincodes:  pc.chaincodes,\n\t\tCollections: pc.collections,\n\t\tNoPrivReads: pc.noPrivReads,\n\t}\n\tcc2collections, err := ccAndCol.parseInput()\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/cmd/endorsers.go#L57-L93","documentation":"EndorsersCmd.Execute builds a channel-scoped endorsers discovery query, which requires a channel name. If pc.channel is nil or empty, the command returns this error before any network call. The channel check is performed first, ahead of the server check.","triggerScenarios":"Running the discovery endorsers command without --channel, or invoking EndorsersCmd.Execute without SetChannel having been called.","commonSituations":"Missing -C/--channel flag on the discovery CLI; empty channel variable in scripts or pipelines; refactors that dropped the SetChannel call in programmatic use.","solutions":["Pass --channel <channel-name> to the endorsers command","Call endorsersCmd.SetChannel(\"mychannel\") before Execute in code","Audit wrapper scripts to ensure the channel argument is passed through"],"exampleFix":"// before\nendorsersCmd.SetServer(\"peer0:7051\")\n// after\nendorsersCmd.SetServer(\"peer0:7051\")\nendorsersCmd.SetChannel(\"mychannel\")","handlingStrategy":"validation","validationCode":"if channel == \"\" {\n    return errors.New(\"--channel is required for the endorsers command\")\n}\nif server == \"\" {\n    return errors.New(\"--server is required for the endorsers command\")\n}","typeGuard":"func endorsersCmdReady(pc *discovery.EndorsersCmd) bool {\n    return pc.Channel != nil && *pc.Channel != \"\" && pc.Server != nil && *pc.Server != \"\"\n}","tryCatchPattern":"if err := endorsersCmd.Execute(conf); err != nil {\n    if strings.Contains(err.Error(), \"no channel specified\") {\n        return fmt.Errorf(\"missing --channel flag: %w\", err)\n    }\n    return err\n}","preventionTips":["Always invoke endorsersCmd with both --channel and --server","Centralize discovery CLI invocations in a helper that enforces required flags","Test scripts with unset env vars to catch missing-argument paths"],"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-08T10:18:20.063Z"}