go-redis/redis · error
no data returned
Error message
no data returned
What it means
Returned by ProcessAggregateResult when the RESP2 FT.AGGREGATE reply array is empty (len 0). The expected RESP2 layout is [total, row, row, ...] with at least the total count, so a zero-length slice means no usable data was returned. This is a client-side decoding guard, not a server-issued error string.
Source
Thrown at search_commands.go:917
if options.Params != nil {
queryArgs = append(queryArgs, "PARAMS", len(options.Params)*2)
for key, value := range options.Params {
queryArgs = append(queryArgs, key, value)
}
}
if options.DialectVersion > 0 {
queryArgs = append(queryArgs, "DIALECT", options.DialectVersion)
} else {
queryArgs = append(queryArgs, "DIALECT", 2)
}
}
return queryArgs, nil
}
func ProcessAggregateResult(data []interface{}) (*FTAggregateResult, error) {
if len(data) == 0 {
return nil, fmt.Errorf("no data returned")
}
total, ok := data[0].(int64)
if !ok {
return nil, fmt.Errorf("invalid total format")
}
rows := make([]AggregateRow, 0, len(data)-1)
for _, row := range data[1:] {
fields, ok := row.([]interface{})
if !ok {
return nil, fmt.Errorf("invalid row format")
}
rowMap := make(map[string]interface{})
for i := 0; i < len(fields); i += 2 {
key, ok := fields[i].(string)
if !ok {View on GitHub (pinned to 36d97525cd)
Solutions
- Inspect cmd.RawVal() / cmd.RawResult() to confirm the reply was actually an empty array.
- Verify the protocol negotiated with the server (Options.Protocol 2 vs 3) matches the reply type the server sent.
- Reproduce the same FT.AGGREGATE with redis-cli to see whether the empty reply originates at the server.
- If a proxy is in the path, bypass it to localize the issue.
Defensive patterns
Strategy: try-catch
Try / catch
res, err := cmd.Result()
if err != nil {
if errors.Is(err, /* wrap of */ errors.New("no data returned")) || err.Error() == "no data returned" {
raw, _ := cmd.RawResult()
log.Printf("empty aggregate reply, raw=%v", raw)
}
return nil, err
} Prevention
- Always inspect cmd.RawResult() when a decode error fires to confirm the actual server reply.
- Verify protocol negotiation (RESP2 vs RESP3) matches the server.
- Bypass RESP-mangling proxies to localize empty-reply issues.
When it happens
Trigger: AggregateCmd.readReply decoding a RESP2 reply whose top-level array has zero elements. Triggered during response decoding; the server returned [] rather than the expected [N, ...rows].
Common situations: A proxy or middleware stripped the response. An unexpected RESP3 reply being interpreted as RESP2 (or vice versa). A server bug returning an empty array. Connection/command instrumentation mangling the frame. Very rarely, an upstream error swallowed into an empty reply.
Related errors
- odd-length key/value array of length %d
- invalid total format
- invalid row format
- invalid field key format
- redis: COLLECT value has type %T, want array of entries
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/1121fdeff87e750a.json.
Report an issue: GitHub.