{"id":"ddcb3f3a819f9184","repo":"go-redis/redis","slug":"invalid-key-type-at-index-d","errorCode":null,"errorMessage":"invalid key type at index %d","messagePattern":"invalid key type at index (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"search_commands.go","lineNumber":3044,"sourceCode":"\nfunc (cmd *FTHybridCmd) RawVal() interface{} {\n\tcmd.await()\n\treturn cmd.rawVal\n}\n\nfunc (cmd *FTHybridCmd) RawResult() (interface{}, error) {\n\tcmd.await()\n\treturn cmd.rawVal, cmd.err\n}\n\nfunc 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","sourceCodeStart":3026,"sourceCodeEnd":3062,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/search_commands.go#L3026-L3062","documentation":"Raised in parseFTHybrid (search_commands.go:3040-3045) when reading FTHybrid (FT.HYBRID? — the FT.HYBRID family) replies as flat key/value pairs: the element at even index must be a string key. A non-string at that position means the reply stream is malformed.","triggerScenarios":"Calling FTHybrid / FTHybridWithArgs and the server returned a flat array whose even-position entries are not strings — typically because the reply is actually a different shape (e.g. nested array or map).","commonSituations":"Version skew between go-redis and the Redis server's hybrid search module, or a reply that wrapped the pairs in an extra level.","solutions":["Inspect cmd.RawVal() / RawResult() to see the actual array contents.","Confirm you are calling FTHybrid against a server that supports it.","Upgrade go-redis and the server module to matched versions.","Reproduce via redis-cli."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"res, cur, err := client.FTHybridWithArgs(ctx, idx, opts).Result()\nif err != nil && strings.Contains(err.Error(), \"invalid key type at index\") {\n    raw, _ := cmd.RawVal()\n    log.Printf(\"fthybrid key slot not string; raw=%#v\", raw)\n}","preventionTips":["Confirm the server supports FT.HYBRID before calling.","Upgrade go-redis and the hybrid module together.","Capture RawVal() for shape diagnosis."],"tags":["redisearch","ft-hybrid","response-parsing"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}