Tencent/WeKnora · error

http read failed: %w

Error message

http read failed: %w

What it means

Transport error in HTTPDocumentReader.Read: the HTTP client's Do() for the document-parse POST failed at the network level (refused, timeout, reset). The %w preserves the underlying error; raised after request construction succeeded and before response status is examined.

Source

Thrown at internal/infrastructure/docparser/http_parser.go:233

	}
	if len(req.FileContent) > 0 {
		body.FileContent = base64.StdEncoding.EncodeToString(req.FileContent)
	}

	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

  1. Verify the docreader HTTP service is up at the configured address
  2. Check network/TLS/timeout settings
  3. Retry once the service is reachable
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/infrastructure/docparser/http_parser.go:233 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/09cc22d3c8ef829e. Report an issue: GitHub.