Tencent/WeKnora · error

read response body: %w

Error message

read response body: %w

What it means

I/O error in PaddleOCRVLReader.callLayoutParsing: io.ReadAll of the response body failed even though the request completed. The %w carries the read error (truncated connection, reset); it fires before the status-code check can examine the response.

Source

Thrown at internal/infrastructure/docparser/paddleocr_vl_converter.go:175

	)
	if err != nil {
		return "", nil, fmt.Errorf("create request: %w", err)
	}
	httpReq.Header.Set("Content-Type", "application/json")

	client := utils.NewSSRFSafeHTTPClient(utils.SSRFSafeHTTPClientConfig{
		Timeout:      paddleOCRVLTimeout,
		MaxRedirects: 5,
	})
	resp, err := client.Do(httpReq)
	if err != nil {
		return "", nil, fmt.Errorf("HTTP request: %w", err)
	}
	defer resp.Body.Close()

	respBody, err := io.ReadAll(resp.Body)
	if err != nil {
		return "", nil, fmt.Errorf("read response body: %w", err)
	}

	if resp.StatusCode != http.StatusOK {
		return "", nil, fmt.Errorf("PaddleOCR-VL API status %d: %s", resp.StatusCode, string(respBody))
	}

	var result paddleOCRVLResponse
	if err := json.Unmarshal(respBody, &result); err != nil {
		return "", nil, fmt.Errorf("decode response: %w", err)
	}
	if result.ErrorCode != 0 {
		return "", nil, fmt.Errorf("PaddleOCR-VL error %d: %s", result.ErrorCode, result.ErrorMsg)
	}

	pages := result.Result.LayoutParsingResults
	if len(pages) == 0 {
		logger.Errorf(context.Background(), "[PaddleOCR-VL] response has no layoutParsingResults")
		return "", nil, nil

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Retry the request; usually transient
  2. Check network stability for large OCR responses
  3. Increase timeout if truncation is systematic
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/infrastructure/docparser/paddleocr_vl_converter.go:175 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/30af6a1a8583769e. Report an issue: GitHub.