{"record":{"id":"63865b1beec09fc9","repo":"hyperledger/fabric","slug":"no-server-specified-63865b","errorCode":null,"errorMessage":"no server specified","messagePattern":"no server specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/cmd/peers.go","lineNumber":56,"sourceCode":"func (pc *PeerCmd) SetServer(server *string) {\n\tpc.server = server\n}\n\n// SetChannel sets the channel of the PeerCmd\nfunc (pc *PeerCmd) SetChannel(channel *string) {\n\tpc.channel = channel\n}\n\n// Execute executes the command\nfunc (pc *PeerCmd) Execute(conf common.Config) error {\n\tchannel := \"\"\n\n\tif pc.channel != nil {\n\t\tchannel = *pc.channel\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\n\treq := discovery.NewRequest()\n\tif channel != \"\" {\n\t\treq = req.OfChannel(channel)\n\t\treq = req.AddPeersQuery()\n\t} else {\n\t\treq = req.AddLocalPeersQuery()\n\t}\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","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/cmd/peers.go#L38-L74","documentation":"The discovery CLI's peers command requires a discovery server (a peer's discovery service endpoint) to send the request to. If the --server flag was not provided or was an empty string, Execute returns this error before any network activity. Discovery is a client-initiated query; there is no default peer to ask.","triggerScenarios":"Running `discover peers` or `discover config` without --server, or with --server \"\" (e.g. an unset shell variable expanded to empty).","commonSituations":"Shell scripts where a $PEER_ADDR variable is unset; forgetting the flag in interactive use; automation templates missing the server argument for one subcommand.","solutions":["Add --server host:port pointing at a peer with discovery service enabled (e.g. --peer0.org1.example.com:7051)","Fix the shell variable so it expands to a non-empty address","Set a default in the wrapper script and validate it is non-empty before invoking discover"],"exampleFix":"// before\ndiscover --configFile conf.yaml peers   # no --server\n\n// after\ndiscover --configFile conf.yaml peers --server peer0.org1.example.com:7051","handlingStrategy":"validation","validationCode":"if (!process.env.DISCOVERY_SERVER || process.env.DISCOVERY_SERVER.trim() === '') {\n  throw new Error('Set DISCOVERY_SERVER (host:port of a peer) before running discover');\n}","typeGuard":"function hasServer(pc) {\n  return typeof pc.server === 'string' && pc.server.trim().length > 0;\n}","tryCatchPattern":"try {\n  execSync(`discover ... --server ${server} peers`);\n} catch (e) {\n  if (String(e).includes('no server specified')) {\n    console.error('Pass --server peer0.org1.example.com:7051');\n  }\n}","preventionTips":["Always pass --server explicitly in scripts","Fail fast on empty shell variables with ${SERVER:?} syntax","Document the peer discovery endpoint in deployment configs"],"tags":["cli","configuration","discovery","missing-argument"],"backgroundTag":"missing-required-flag","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"}