{"record":{"id":"2cec43950f6a9c78","repo":"hyperledger/fabric","slug":"empty-results","errorCode":null,"errorMessage":"empty results","messagePattern":"empty results","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/cmd/endorsers.go","lineNumber":127,"sourceCode":"\n\tres, err := pc.stub.Send(server, conf, req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn pc.parser.ParseResponse(channel, res)\n}\n\n// EndorserResponseParser parses endorsement responses from the peer\ntype EndorserResponseParser struct {\n\tio.Writer\n}\n\n// ParseResponse parses the given response for the given channel\nfunc (parser *EndorserResponseParser) ParseResponse(channel string, res ServiceResponse) error {\n\trawResponse := res.Raw()\n\tif len(rawResponse.Results) == 0 {\n\t\treturn errors.New(\"empty results\")\n\t}\n\n\tif e := rawResponse.Results[0].GetError(); e != nil {\n\t\treturn errors.Errorf(\"server returned: %s\", e.Content)\n\t}\n\n\tccQueryRes := rawResponse.Results[0].GetCcQueryRes()\n\tif ccQueryRes == nil {\n\t\treturn errors.Errorf(\"server returned response of unexpected type: %v\", reflect.TypeFor[*discovery.QueryResult]())\n\t}\n\n\tjsonBytes, _ := json.MarshalIndent(parseEndorsementDescriptors(ccQueryRes.Content), \"\", \"\\t\")\n\tfmt.Fprintln(parser.Writer, string(jsonBytes))\n\treturn nil\n}\n\ntype chaincodesAndCollections struct {\n\tChaincodes  *[]string","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/cmd/endorsers.go#L109-L145","documentation":"EndorserResponseParser.ParseResponse reads the raw discovery response and expects at least one result. An empty Results array means the server responded but contained no query results, which the parser treats as an invalid response rather than a legitimate empty answer. This can indicate a protocol/version mismatch or a degenerate server response.","triggerScenarios":"Calling ParseResponse with a ServiceResponse whose raw proto response has len(Results) == 0 — e.g. the server returned a discovery.Response with no results array populated.","commonSituations":"Peer/discovery service version mismatch producing a malformed response; server-side error swallowed into an empty response; querying with a request that produced no results but no error status.","solutions":["Check the peer version and upgrade the discovery client/peer to compatible versions","Enable debug logging on the peer to see how the response was produced","Retry the discovery query; if persistent, verify the channel and chaincode exist on the peer"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"raw := res.Raw()\nif len(raw.Results) == 0 {\n    return errors.New(\"discovery response has no results; check peer version and channel\")\n}","typeGuard":"func hasResults(res discovery.ServiceResponse) bool {\n    return len(res.Raw().Results) > 0\n}","tryCatchPattern":"if err := parser.ParseResponse(channel, res); err != nil {\n    if err.Error() == \"empty results\" {\n        return fmt.Errorf(\"peer returned no discovery results (verify peer version/channel): %w\", err)\n    }\n    return err\n}","preventionTips":["Keep discovery client and peer versions aligned","Retry discovery queries once before failing on empty results","Log raw responses when debugging discovery issues"],"tags":["go","discovery","response-parsing","protocol"],"backgroundTag":"empty-server-response","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"}