{"record":{"id":"34379a7172ab5807","repo":"redis/go-redis","slug":"invalid-synonyms-format","errorCode":null,"errorMessage":"invalid synonyms format","messagePattern":"invalid synonyms format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"search_commands.go","lineNumber":3637,"sourceCode":"\t\treturn err\n\t}\n\n\t// RESP2 format\n\ttermSynonymPairs, err := rd.ReadSlice()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar results []FTSynDumpResult\n\tfor i := 0; i < len(termSynonymPairs); i += 2 {\n\t\tterm, ok := termSynonymPairs[i].(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"invalid term format\")\n\t\t}\n\n\t\tsynonyms, ok := termSynonymPairs[i+1].([]interface{})\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"invalid synonyms format\")\n\t\t}\n\n\t\tsynonymList := make([]string, len(synonyms))\n\t\tfor j, syn := range synonyms {\n\t\t\tsynonym, ok := syn.(string)\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"invalid synonym format\")\n\t\t\t}\n\t\t\tsynonymList[j] = synonym\n\t\t}\n\n\t\tresults = append(results, FTSynDumpResult{\n\t\t\tTerm:     term,\n\t\t\tSynonyms: synonymList,\n\t\t})\n\t}\n\n\tcmd.val = results","sourceCodeStart":3619,"sourceCodeEnd":3655,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/search_commands.go#L3619-L3655","documentation":"In the RESP2 FTSYNUMP parse path, each odd-position element must be a []interface{} of synonym strings. If it is not a slice, the client fails with this error while building FTSynDumpResult entries.","triggerScenarios":"Reading an FTSynDump reply over RESP2 where a synonym-list position decodes to something other than []interface{} (e.g. a single string instead of an array), often from a malformed mock or shifting caused by a bad term/synonym pairing.","commonSituations":"Mocked FTSYNUMP responses listing synonyms as a scalar; proxy rewriting replies; index-shifted replies where a synonym lands on a term slot.","solutions":["Ensure the reply models synonyms as a RESP array per term.","Switch to Protocol: 3 to use the map-based RESP3 parser.","Correct test fixtures so each pair is [string, []interface{}]."],"exampleFix":"// before: []interface{}{\"term\", \"syn1\"}\n// after:  []interface{}{\"term\", []interface{}{\"syn1\"}}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"syns, ok := pairs[i+1].([]interface{})\nif !ok { /* malformed synonym-list slot */ }","tryCatchPattern":"res, err := client.FTSynDump(ctx, \"idx\").Result()\nif err != nil && strings.Contains(err.Error(), \"invalid synonyms format\") {\n    // inspect raw reply; fix mock or proxy\n}","preventionTips":["Ensure synonyms are RESP arrays per term","Prefer RESP3 (map) parsing","Validate test fixtures against real server captures"],"tags":["search","parsing","resp2","ft-syndump"],"backgroundTag":"unexpected-response-type","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}