hyperledger/fabric · error

empty results

Error message

empty results

What it means

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.

Source

Thrown at discovery/cmd/endorsers.go:127

	res, err := pc.stub.Send(server, conf, req)
	if err != nil {
		return err
	}

	return pc.parser.ParseResponse(channel, res)
}

// EndorserResponseParser parses endorsement responses from the peer
type EndorserResponseParser struct {
	io.Writer
}

// ParseResponse parses the given response for the given channel
func (parser *EndorserResponseParser) ParseResponse(channel string, res ServiceResponse) error {
	rawResponse := res.Raw()
	if len(rawResponse.Results) == 0 {
		return errors.New("empty results")
	}

	if e := rawResponse.Results[0].GetError(); e != nil {
		return errors.Errorf("server returned: %s", e.Content)
	}

	ccQueryRes := rawResponse.Results[0].GetCcQueryRes()
	if ccQueryRes == nil {
		return errors.Errorf("server returned response of unexpected type: %v", reflect.TypeFor[*discovery.QueryResult]())
	}

	jsonBytes, _ := json.MarshalIndent(parseEndorsementDescriptors(ccQueryRes.Content), "", "\t")
	fmt.Fprintln(parser.Writer, string(jsonBytes))
	return nil
}

type chaincodesAndCollections struct {
	Chaincodes  *[]string

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Check the peer version and upgrade the discovery client/peer to compatible versions
  2. Enable debug logging on the peer to see how the response was produced
  3. Retry the discovery query; if persistent, verify the channel and chaincode exist on the peer
Defensive patterns

Strategy: try-catch

Validate before calling

raw := res.Raw()
if len(raw.Results) == 0 {
    return errors.New("discovery response has no results; check peer version and channel")
}

Type guard

func hasResults(res discovery.ServiceResponse) bool {
    return len(res.Raw().Results) > 0
}

Try / catch

if err := parser.ParseResponse(channel, res); err != nil {
    if err.Error() == "empty results" {
        return fmt.Errorf("peer returned no discovery results (verify peer version/channel): %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/2cec43950f6a9c78. Report an issue: GitHub.