{"id":"7684954bacd32e9a","repo":"go-redis/redis","slug":"invalid-score-format","errorCode":null,"errorMessage":"invalid score format","messagePattern":"invalid score format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"search_commands.go","lineNumber":2638,"sourceCode":"\t\t\treturn FTSearchResult{}, fmt.Errorf(\"invalid document ID format\")\n\t\t}\n\n\t\tdoc := Document{\n\t\t\tID:     docID,\n\t\t\tFields: make(map[string]string),\n\t\t}\n\t\ti++\n\n\t\tif noContent {\n\t\t\tresults = append(results, doc)\n\t\t\tcontinue\n\t\t}\n\n\t\tif withScores && i < len(data) {\n\t\t\tif scoreStr, ok := data[i].(string); ok {\n\t\t\t\tscore, err := strconv.ParseFloat(scoreStr, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn FTSearchResult{}, fmt.Errorf(\"invalid score format\")\n\t\t\t\t}\n\t\t\t\tdoc.Score = &score\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\n\t\tif withPayloads && i < len(data) {\n\t\t\tif payload, ok := data[i].(string); ok {\n\t\t\t\tdoc.Payload = &payload\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\n\t\tif withSortKeys && i < len(data) {\n\t\t\tif sortKey, ok := data[i].(string); ok {\n\t\t\t\tdoc.SortKey = &sortKey\n\t\t\t\ti++\n\t\t\t}","sourceCodeStart":2620,"sourceCodeEnd":2656,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/search_commands.go#L2620-L2656","documentation":"Raised in parseFTSearch (search_commands.go:2635-2638) when WITHSCORES was requested, the score element decoded as a string, but strconv.ParseFloat could not parse it into a float64. FT.SEARCH scores are textual floating-point; a non-numeric token here means the reply is malformed.","triggerScenarios":"Calling FTSearchWithArgs with WithScores:true against a reply where the score slot contains a non-numeric string (e.g. 'NaN', 'inf' in unexpected casing, or a sentinel like '__deleted__'), or where flag misalignment placed a field value where the score should be.","commonSituations":"Custom scorer returning unusual values, an upstream RESP proxy rewriting numbers, or version skew between the client parser and a newer Redis Stack release.","solutions":["Run the same query in redis-cli with WITHSCORES and inspect the score tokens.","Verify WithScores is the only relevant flag and the schema actually scores documents.","Upgrade go-redis and Redis Stack to matched, current versions.","If you control the scorer, ensure it emits parseable floats."],"exampleFix":"// before\nopts := &redis.FTSearchOptions{WithScores: true}\nres, err := client.FTSearchWithArgs(ctx, idx, q, opts).Result()\n// after — confirm scores parse via raw inspection\nraw, _ := client.FTSearchWithArgs(ctx, idx, q, opts).RawResult()\nlog.Printf(\"raw=%#v\", raw)","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"res, err := client.FTSearchWithArgs(ctx, idx, q, &redis.FTSearchOptions{WithScores: true}).Result()\nif err != nil && strings.Contains(err.Error(), \"invalid score format\") {\n    raw, _ := client.FTSearchWithArgs(ctx, idx, q, &redis.FTSearchOptions{WithScores: true}).RawResult()\n    log.Printf(\"score not parseable; raw=%#v\", raw)\n}","preventionTips":["Use standard scorers (TFIDF, BM25) to ensure parseable numeric scores.","Run the query in redis-cli first to eyeball score tokens.","Upgrade Redis Stack and go-redis together."],"tags":["redisearch","ft-search","score-parsing","strconv"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}