{"record":{"id":"bcfc147dfbd761fd","repo":"weaviate/weaviate","slug":"failed-to-parse-reranker-response-status-d-w-bcfc14","errorCode":null,"errorMessage":"failed to parse reranker response (status %d): %w","messagePattern":"failed to parse reranker response \\(status (.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/reranker-voyageai/clients/ranker.go","lineNumber":153,"sourceCode":"\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"read response body\")\n\t}\n\n\tif res.StatusCode != 200 {\n\t\tvar apiError voyageAiApiError\n\t\terr = json.Unmarshal(bodyBytes, &apiError)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"unmarshal error from response body\")\n\t\t}\n\t\tif apiError.Message != \"\" {\n\t\t\treturn nil, errors.Errorf(\"connection to VoyageAI API failed with status %d: %s\", res.StatusCode, apiError.Message)\n\t\t}\n\t\treturn nil, errors.Errorf(\"connection to VoyageAI API failed with status %d\", res.StatusCode)\n\t}\n\n\tvar rankResponse RankResponse\n\tif err := json.Unmarshal(bodyBytes, &rankResponse); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse reranker response (status %d): %w\", res.StatusCode, err)\n\t}\n\treturn c.toDocumentScores(documents, rankResponse.Data), nil\n}\n\nfunc (c *client) chunkDocuments(documents []string, chunkSize int) [][]string {\n\tvar requests [][]string\n\tfor i := 0; i < len(documents); i += chunkSize {\n\t\tend := i + chunkSize\n\n\t\tif end > len(documents) {\n\t\t\tend = len(documents)\n\t\t}\n\n\t\trequests = append(requests, documents[i:end])\n\t}\n\n\treturn requests\n}","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/reranker-voyageai/clients/ranker.go#L135-L171","documentation":"Returned by the VoyageAI reranker client when the JSON body of a response from the VoyageAI rerank endpoint cannot be unmarshaled into the expected RankResponse (containing a 'data' array). The original unmarshal error is wrapped so the root cause (type mismatch, unexpected JSON) is preserved. The status code is included, and unlike the transformers client, this parse only runs after non-2xx statuses were already handled.","triggerScenarios":"VoyageAI returns a 200 response whose body does not match RankResponse — e.g. schema change on VoyageAI's side, a truncated/chunked body corrupted during reading, or an unexpected JSON envelope.","commonSituations":"VoyageAI API response format changes; document chunks producing malformed responses; network intermediary altering the body; using a rerank model whose response shape differs from the client's expectation.","solutions":["Log/inspect the raw response body to see what VoyageAI actually returned","Pin/verify the voyageai rerank model name matches one with the documented response shape (voyage-rerank-*)","Update the client's RankResponse struct if VoyageAI changed their schema","Check for proxies or network issues that could truncate the response body"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify API key and model are set before calls\nif apiKey == \"\" || !strings.HasPrefix(model, \"rerank-\") {\n\treturn errors.New(\"voyageai reranker requires API key and a valid rerank model\")\n}","typeGuard":"func isVoyageParseFailure(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"failed to parse reranker response\")\n}","tryCatchPattern":"scores, err := client.PerformRank(ctx, query, docs)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to parse reranker response\") {\n\t\t// dump raw body for schema comparison, then report\n\t}\n\treturn err\n}","preventionTips":["Use documented voyage rerank models (e.g. rerank-1/rerank-2) only","Watch VoyageAI changelogs for response schema changes","Log raw bodies on parse failure to ease diagnosis","Test the client against VoyageAI after any API version bump"],"tags":["voyageai","reranker","json-parsing","http"],"backgroundTag":"api-response-parse-failed","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}