{"record":{"id":"6a7aed334f595d69","repo":"Tencent/WeKnora","slug":"http-read-status-d-s","errorCode":null,"errorMessage":"http read status %d: %s","messagePattern":"http read status (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/docparser/http_parser.go","lineNumber":238,"sourceCode":"\tjsonBody, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"http marshal read request: %w\", err)\n\t}\n\thttpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, base+PathRead, bytes.NewReader(jsonBody))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"http new request: %w\", err)\n\t}\n\thttpReq.Header.Set(\"Content-Type\", \"application/json\")\n\thttpReq.ContentLength = int64(len(jsonBody))\n\n\tresp, err := p.client.Do(httpReq)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"http read failed: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\tbodyBytes, _ := io.ReadAll(resp.Body)\n\t\treturn nil, fmt.Errorf(\"http read status %d: %s\", resp.StatusCode, string(bodyBytes))\n\t}\n\tvar out httpReadResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&out); err != nil {\n\t\treturn nil, fmt.Errorf(\"http decode read response: %w\", err)\n\t}\n\treturn fromHTTPReadResponse(&out), nil\n}\n","sourceCodeStart":220,"sourceCodeEnd":246,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/docparser/http_parser.go#L220-L246","documentation":"This error wraps a failed HTTP document-parse request whose response status was not 200. The remote HTTP parser returned a non-OK status and the response body is included in the message for diagnostics. It is thrown by the Read method of the HTTP-backed document parser when the backend service rejects or fails the read.","triggerScenarios":"Calling Read on the HTTP doc parser when the remote parse service responds with e.g. 400/404/500/503; body of the error contains the upstream response text.","commonSituations":"Parse service down or deploying (503), malformed document ID or payload (400), wrong service URL or port configured, auth/proxy rejecting the request (401/403), upstream timeout producing 500.","solutions":["Inspect the status code and body in the error message to identify the upstream failure","Verify the HTTP parser service URL and endpoint configuration","Confirm the document/URL passed to Read is valid and reachable by the parser service","Check parser service logs for the correlated request and retry with backoff for 5xx"],"exampleFix":"// before\nresp, _ := client.Do(req) // parser service returns 503 during deploy\n// after\n// retry on transient statuses\nif resp.StatusCode == http.StatusServiceUnavailable || resp.StatusCode == http.StatusBadGateway {\n    time.Sleep(backoff)\n    resp, err = client.Do(req)\n}","handlingStrategy":"try-catch","validationCode":"// check the parser endpoint is reachable before calling Read\nresp, err := http.Head(parserURL + \"/health\")\nif err != nil || resp.StatusCode != http.StatusOK {\n    return fmt.Errorf(\"parser service unavailable: %v %v\", err, resp)\n}","typeGuard":null,"tryCatchPattern":"out, err := parser.Read(ctx, doc)\nif err != nil {\n    var statusErr interface{ Error() string }\n    _ = statusErr\n    if strings.Contains(err.Error(), \"http read status 5\") {\n        // transient upstream failure: retry with backoff\n    }\n    return fmt.Errorf(\"document parse failed: %w\", err)\n}","preventionTips":["Health-check the parser service before batch jobs","Alert on 5xx rates from the parser service","Pin and version the parser service URL in config","Include document ID in logs to correlate with parser-side traces"],"tags":["http","network","docparser"],"backgroundTag":"http-non-2xx-status","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}