Tencent/WeKnora · error
http read status %d: %s
Error message
http read status %d: %s
What it means
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.
Source
Thrown at internal/infrastructure/docparser/http_parser.go:238
jsonBody, err := json.Marshal(body)
if err != nil {
return nil, fmt.Errorf("http marshal read request: %w", err)
}
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, base+PathRead, bytes.NewReader(jsonBody))
if err != nil {
return nil, fmt.Errorf("http new request: %w", err)
}
httpReq.Header.Set("Content-Type", "application/json")
httpReq.ContentLength = int64(len(jsonBody))
resp, err := p.client.Do(httpReq)
if err != nil {
return nil, fmt.Errorf("http read failed: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
bodyBytes, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("http read status %d: %s", resp.StatusCode, string(bodyBytes))
}
var out httpReadResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
return nil, fmt.Errorf("http decode read response: %w", err)
}
return fromHTTPReadResponse(&out), nil
}
View on GitHub (pinned to 988cbb0330)
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
Example fix
// before
resp, _ := client.Do(req) // parser service returns 503 during deploy
// after
// retry on transient statuses
if resp.StatusCode == http.StatusServiceUnavailable || resp.StatusCode == http.StatusBadGateway {
time.Sleep(backoff)
resp, err = client.Do(req)
} Defensive patterns
Strategy: try-catch
Validate before calling
// check the parser endpoint is reachable before calling Read
resp, err := http.Head(parserURL + "/health")
if err != nil || resp.StatusCode != http.StatusOK {
return fmt.Errorf("parser service unavailable: %v %v", err, resp)
} Try / catch
out, err := parser.Read(ctx, doc)
if err != nil {
var statusErr interface{ Error() string }
_ = statusErr
if strings.Contains(err.Error(), "http read status 5") {
// transient upstream failure: retry with backoff
}
return fmt.Errorf("document parse failed: %w", err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/6a7aed334f595d69.
Report an issue: GitHub.