{"record":{"id":"c42b20c6ba811828","repo":"redis/go-redis","slug":"invalid-result-item-format","errorCode":null,"errorMessage":"invalid result item format","messagePattern":"invalid result item format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"search_commands.go","lineNumber":3098,"sourceCode":"\t\t\tcontinue\n\t\t}\n\n\t\t// Try parsing as map[interface{}]interface{} (alternative RESP3 format)\n\t\tif rawMap, ok := item.(map[interface{}]interface{}); ok {\n\t\t\titemMap := make(map[string]interface{})\n\t\t\tfor k, v := range rawMap {\n\t\t\t\tif keyStr, ok := k.(string); ok {\n\t\t\t\t\titemMap[keyStr] = v\n\t\t\t\t}\n\t\t\t}\n\t\t\tresults = append(results, itemMap)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Fall back to array format (RESP2 format - key-value pairs)\n\t\titemData, ok := item.([]interface{})\n\t\tif !ok {\n\t\t\treturn FTHybridResult{}, nil, fmt.Errorf(\"invalid result item format\")\n\t\t}\n\n\t\titemMap := make(map[string]interface{})\n\t\tfor i := 0; i < len(itemData); i += 2 {\n\t\t\tif i+1 < len(itemData) {\n\t\t\t\tkey, ok := itemData[i].(string)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn FTHybridResult{}, nil, fmt.Errorf(\"invalid item key format\")\n\t\t\t\t}\n\t\t\t\titemMap[key] = itemData[i+1]\n\t\t\t}\n\t\t}\n\t\tresults = append(results, itemMap)\n\t}\n\n\t// Optional warnings; accept both \"warning\" (as FT.SEARCH/FT.AGGREGATE) and \"warnings\".\n\tvar warnings []string\n\twarningsData, ok := resultMap[\"warning\"].([]interface{})","sourceCodeStart":3080,"sourceCodeEnd":3116,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/search_commands.go#L3080-L3116","documentation":"Within FT.HYBRID results, each item should be either a RESP3 map or a RESP2 flat key/value array. If an item is neither (e.g. a scalar or nested unexpected type), the parser cannot extract fields and returns this error. It means one result row arrived in an unrecognized shape.","triggerScenarios":"Calling FTHybrid when an element of the \"results\" array is neither map-like nor []interface{} — typically due to a server/proxy producing corrupted or non-standard rows.","commonSituations":"RESP-transforming proxies or compression layers altering row types; exotic server builds; malformed mock data in tests.","solutions":["Verify with a raw reply dump (hook/MONITOR) what type the offending row is","Remove any middleware that transforms individual result rows","Align server and go-redis versions on the FT.HYBRID reply contract","Fix mocks so each result item is map[interface{}]interface{} or a flat []interface{}"],"exampleFix":"// before\n\"results\": []interface{}{\"corrupt-row\"}\n// after\n\"results\": []interface{}{[]interface{}{\"id\", \"doc1\"}}","handlingStrategy":"type-guard","validationCode":"// validate one known-good hybrid call before exposing the feature\nif _, err := rdb.FTHybrid(ctx, \"idx\", \"*\", opts).Result(); err != nil { /* disable feature */ }","typeGuard":"func isResultItem(item interface{}) bool {\n    switch item.(type) {\n    case map[interface{}]interface{}, []interface{}:\n        return true\n    }\n    return false\n}","tryCatchPattern":"res, _, err := hybridCmd.Result()\nif err != nil && strings.Contains(err.Error(), \"invalid result item format\") {\n    // dump raw reply via hook and report; treat as upstream incompatibility\n    return ErrMalformedReply\n}","preventionTips":["Keep client/server versions compatible","Avoid proxies that rewrite individual reply rows","Fuzz your fixtures: every result row must be a map or flat pair array"],"tags":["redis","search","resp-protocol","deserialization"],"backgroundTag":"unexpected-response-shape","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}