{"record":{"id":"7f31de395634c625","repo":"siyuan-note/siyuan","slug":"rerank-http-d-s","errorCode":null,"errorMessage":"rerank HTTP %d: %s","messagePattern":"rerank HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/openai.go","lineNumber":568,"sourceCode":"\treq.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n\n\tctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second)\n\tdefer cancel()\n\treq = req.WithContext(ctx)\n\n\tresp, err := getRerankHTTPClient().Do(req)\n\tif nil != err {\n\t\tlogging.LogErrorf(\"rerank request failed: %s\", err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, err := io.ReadAll(resp.Body)\n\tif nil != err {\n\t\treturn\n\t}\n\tif http.StatusOK != resp.StatusCode {\n\t\terr = fmt.Errorf(\"rerank HTTP %d: %s\", resp.StatusCode, string(respBody))\n\t\tlogging.LogErrorf(\"rerank failed: %s\", err)\n\t\treturn\n\t}\n\n\tvar rr rerankResponse\n\tif err = json.Unmarshal(respBody, &rr); nil != err {\n\t\treturn\n\t}\n\n\tfor _, r := range rr.Results {\n\t\tif r.Index < 0 || r.Index >= len(documents) {\n\t\t\tcontinue\n\t\t}\n\t\tindices = append(indices, r.Index)\n\t\tscores = append(scores, r.RelevanceScore)\n\t}\n\treturn\n}","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/util/openai.go#L550-L586","documentation":"Rerank surfaces any non-200 response from the rerank endpoint with this status+body message so the user sees the provider's actual error. Rerank endpoint paths are provider-specific (Jina /v1/rerank, Cohere /v1/rerank, Aliyun compatible-api/v1/reranks), so misconfiguration is the most common cause.","triggerScenarios":"Wrong rerank endpoint URL (base instead of full path); 401 API key not authorized for rerank; 404 model not found; 422 malformed request; 429 rate limit; 5xx provider error.","commonSituations":"Endpoint field filled with only the base URL; API key issued for chat but not rerank; model name typo; provider does not expose rerank at all.","solutions":["Set the rerank endpoint to the provider's FULL rerank path per their docs, not just the base.","Use an API key authorized for rerank models.","Verify the model name against the provider's catalog.","Read the body in the message; it states the upstream reason."],"exampleFix":"# before: endpoint = https://api.jina.ai/v1        -> rerank HTTP 404\n# after:  endpoint = https://api.jina.ai/v1/rerank","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, _, err := util.Rerank(q, docs, key, endpoint, model, 0, 30); err != nil {\n    return fmt.Errorf(\"rerank provider error: %w\", err) // err already has status+body\n}","preventionTips":["Use the provider's documented full rerank endpoint path","Validate the model name against the provider's catalog","Test connectivity with TestRerankModel before enabling rerank in search"],"tags":["ai","rerank","network","go","auth"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}