{"id":"be265a31fb985e33","repo":"go-redis/redis","slug":"invalid-cursor-result-format","errorCode":null,"errorMessage":"invalid cursor result format","messagePattern":"invalid cursor result format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"search_commands.go","lineNumber":3055,"sourceCode":"func parseFTHybrid(data []interface{}, withCursor bool) (FTHybridResult, *FTHybridCursorResult, error) {\n\t// Convert to map\n\tresultMap := make(map[string]interface{})\n\tfor i := 0; i < len(data); i += 2 {\n\t\tif i+1 < len(data) {\n\t\t\tkey, ok := data[i].(string)\n\t\t\tif !ok {\n\t\t\t\treturn FTHybridResult{}, nil, fmt.Errorf(\"invalid key type at index %d\", i)\n\t\t\t}\n\t\t\tresultMap[key] = data[i+1]\n\t\t}\n\t}\n\n\t// Handle cursor result\n\tif withCursor {\n\t\tsearchCursorID, ok1 := resultMap[\"SEARCH\"].(int64)\n\t\tvsimCursorID, ok2 := resultMap[\"VSIM\"].(int64)\n\t\tif !ok1 || !ok2 {\n\t\t\treturn FTHybridResult{}, nil, fmt.Errorf(\"invalid cursor result format\")\n\t\t}\n\t\treturn FTHybridResult{}, &FTHybridCursorResult{\n\t\t\tSearchCursorID: int(searchCursorID),\n\t\t\tVsimCursorID:   int(vsimCursorID),\n\t\t}, nil\n\t}\n\n\t// Parse regular result\n\ttotalResults, ok := resultMap[\"total_results\"].(int64)\n\tif !ok {\n\t\treturn FTHybridResult{}, nil, fmt.Errorf(\"invalid total_results format\")\n\t}\n\n\tresultsData, ok := resultMap[\"results\"].([]interface{})\n\tif !ok {\n\t\treturn FTHybridResult{}, nil, fmt.Errorf(\"invalid results format\")\n\t}\n","sourceCodeStart":3037,"sourceCodeEnd":3073,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/search_commands.go#L3037-L3073","documentation":"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.","triggerScenarios":"Calling FTHybridWithArgs with WithCursor:true where the server reply's SEARCH/VSIM fields are missing, nil, or non-integer (e.g. strings).","commonSituations":"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.","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."],"exampleFix":"// before\nopts := &redis.FTHybridOptions{WithCursor: true, /* ... */}\ncur, err := client.FTHybridWithArgs(ctx, idx, opts).CursorResult()\n// after — only request cursor when the server supports integer cursors\nopts := &redis.FTHybridOptions{/* WithCursor omitted */}\nres, err := client.FTHybridWithArgs(ctx, idx, opts).Result()","handlingStrategy":"validation","validationCode":"// Only request WithCursor when the server hybrid module emits integer SEARCH/VSIM cursors.\nif !serverSupportsIntCursors {\n    opts.WithCursor = false\n}","typeGuard":null,"tryCatchPattern":"cur, err := client.FTHybridWithArgs(ctx, idx, opts).CursorResult()\nif err != nil && strings.Contains(err.Error(), \"invalid cursor result format\") {\n    raw, _ := cmd.RawVal()\n    log.Printf(\"fthybrid cursor not int64 pair; raw=%#v\", raw)\n}","preventionTips":["Verify server-side cursor support before enabling WithCursor.","Upgrade the hybrid module to emit integer cursors.","Inspect RawVal() for the SEARCH/VSIM values."],"tags":["redisearch","ft-hybrid","cursor","response-parsing"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}