go-redis/redis · error

invalid row format

Error message

invalid row format

What it means

Returned by ProcessAggregateResult when an element of the RESP2 reply (after the total) is not a []interface{}. Each row in FT.AGGREGATE RESP2 is itself a flat array of [key, value, key, value, ...]; a row that is a string, nil, or any non-array type triggers this guard.

Source

Thrown at search_commands.go:929

	}
	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 {
				return nil, fmt.Errorf("invalid field key format")
			}
			value := fields[i+1]
			rowMap[key] = value
		}
		rows = append(rows, AggregateRow{Fields: rowMap})
	}

	result := &FTAggregateResult{
		Total: int(total),
		Rows:  rows,
	}

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Inspect cmd.RawVal() to identify the offending row element and its type.
  2. Verify the negotiated protocol (RESP2 vs RESP3) matches the server reply.
  3. Reproduce with redis-cli to see whether the malformed row originates at the server.
  4. Check for proxies or middleware that may rewrite the reply.
Defensive patterns

Strategy: try-catch

Try / catch

res, err := cmd.Result()
if err != nil && strings.Contains(err.Error(), "invalid row format") {
    raw, _ := cmd.RawResult()
    log.Printf("aggregate row not array; raw=%v", raw)
}
return err

Prevention

When it happens

Trigger: AggregateCmd.readReply decoding a RESP2 reply where data[i] (i >= 1) is not a slice. Triggered during response decoding while iterating rows.

Common situations: Server returned an error or status string interleaved with rows. RESP3/RESP2 mismatch. Proxy corrupting the frame. A row containing a nested non-array element due to a server bug.

Related errors


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/01166cf98282401f.json. Report an issue: GitHub.