Tencent/WeKnora · error

decode response: %w

Error message

decode response: %w

What it means

Deserialization error in PaddleOCRVLReader.callLayoutParsing: the 200 response body could not be unmarshaled into paddleOCRVLResponse. The %w wraps the JSON error, indicating the PaddleOCR-VL service returned a schema the client cannot parse; the ErrorCode check follows only after successful decode.

Source

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

	})
	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
	}

	// Merge per-page markdown and image dicts into one document.
	texts := make([]string, 0, len(pages))
	images := make(map[string]string)
	for _, p := range pages {
		if t := strings.TrimSpace(p.Markdown.Text); t != "" {
			texts = append(texts, p.Markdown.Text)
		}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Log a body snippet to inspect the actual payload
  2. Check for proxies rewriting responses
  3. Verify the PaddleOCR-VL API contract version
Defensive patterns

Strategy: try-catch

When it happens

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