go-redis/redis · error
invalid cursor result format
Error message
invalid cursor result format
What it means
Returned in parseFTHybrid (search_commands.go:3051-3056) when WithCursor was requested but the result map's 'SEARCH' and 'VSIM' entries are not both int64 cursor IDs. The cursor-result shape must contain two integer cursors.
Source
Thrown at search_commands.go:3055
func parseFTHybrid(data []interface{}, withCursor bool) (FTHybridResult, *FTHybridCursorResult, error) {
// Convert to map
resultMap := make(map[string]interface{})
for i := 0; i < len(data); i += 2 {
if i+1 < len(data) {
key, ok := data[i].(string)
if !ok {
return FTHybridResult{}, nil, fmt.Errorf("invalid key type at index %d", i)
}
resultMap[key] = data[i+1]
}
}
// Handle cursor result
if withCursor {
searchCursorID, ok1 := resultMap["SEARCH"].(int64)
vsimCursorID, ok2 := resultMap["VSIM"].(int64)
if !ok1 || !ok2 {
return FTHybridResult{}, nil, fmt.Errorf("invalid cursor result format")
}
return FTHybridResult{}, &FTHybridCursorResult{
SearchCursorID: int(searchCursorID),
VsimCursorID: int(vsimCursorID),
}, nil
}
// Parse regular result
totalResults, ok := resultMap["total_results"].(int64)
if !ok {
return FTHybridResult{}, nil, fmt.Errorf("invalid total_results format")
}
resultsData, ok := resultMap["results"].([]interface{})
if !ok {
return FTHybridResult{}, nil, fmt.Errorf("invalid results format")
}
View on GitHub (pinned to 36d97525cd)
Solutions
- Verify WithCursor is supported by the server hybrid module version.
- Inspect RawResult() to confirm the SEARCH and VSIM values and their Go types.
- Upgrade the server module so cursors are returned as integers.
- Drop WithCursor if cursor paging is not required.
Example fix
// before
opts := &redis.FTHybridOptions{WithCursor: true, /* ... */}
cur, err := client.FTHybridWithArgs(ctx, idx, opts).CursorResult()
// after — only request cursor when the server supports integer cursors
opts := &redis.FTHybridOptions{/* WithCursor omitted */}
res, err := client.FTHybridWithArgs(ctx, idx, opts).Result() Defensive patterns
Strategy: validation
Validate before calling
// Only request WithCursor when the server hybrid module emits integer SEARCH/VSIM cursors.
if !serverSupportsIntCursors {
opts.WithCursor = false
} Try / catch
cur, err := client.FTHybridWithArgs(ctx, idx, opts).CursorResult()
if err != nil && strings.Contains(err.Error(), "invalid cursor result format") {
raw, _ := cmd.RawVal()
log.Printf("fthybrid cursor not int64 pair; raw=%#v", raw)
} Prevention
- Verify server-side cursor support before enabling WithCursor.
- Upgrade the hybrid module to emit integer cursors.
- Inspect RawVal() for the SEARCH/VSIM values.
When it happens
Trigger: Calling FTHybridWithArgs with WithCursor:true where the server reply's SEARCH/VSIM fields are missing, nil, or non-integer (e.g. strings).
Common situations: Server-side hybrid module version that emits cursor IDs as strings, or a reply missing one of the cursor keys because the query did not actually use cursors server-side.
Related errors
- invalid key type at index %d
- invalid total_results format
- invalid results format
- invalid result item format
- invalid item key format
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/be265a31fb985e33.json.
Report an issue: GitHub.