PaddlePaddle/PaddleOCR · error · ResultParseError

OCR result page is missing prunedResult.

Error message

OCR result page is missing prunedResult.

What it means

Raised as NetworkError from submit_file in paddleocr/_api_client/_http.py:155 when the multipart upload POST fails at connection level: reset during transfer, DNS failure, TLS error, or refused connection. Mid-upload resets are common with flaky networks and aggressive proxies. The upload did not complete; job state server-side is indeterminate.

Source

Thrown at api_sdk/typescript/src/client.ts:287

    return this.http.submitFile(model, req.filePath!, payload, {
      pageRanges: req.pageRanges,
      batchId: req.batchId,
      signal,
    });
  }

  private parseOCRResult(jobId: string, jsonlData: unknown[]): OCRResult {
    const dataInfo: Record<string, unknown> = {};
    const pages = jsonlData.flatMap((lineObj) => {
      if (!isRecord(lineObj) || !isRecord(lineObj.result) || !Array.isArray(lineObj.result.ocrResults)) {
        throw new ResultParseError("OCR result item is missing result.ocrResults.");
      }
      if (isRecord(lineObj.result.dataInfo)) {
        Object.assign(dataInfo, lineObj.result.dataInfo);
      }
      return lineObj.result.ocrResults.map((item) => {
        if (!isRecord(item) || !("prunedResult" in item)) {
          throw new ResultParseError("OCR result page is missing prunedResult.");
        }
        return {
          prunedResult: item.prunedResult,
          ocrImageUrl: typeof item.ocrImage === "string" ? item.ocrImage : undefined,
          docPreprocessingImageUrl: typeof item.docPreprocessingImage === "string" ? item.docPreprocessingImage : undefined,
          inputImageUrl: typeof item.inputImage === "string" ? item.inputImage : undefined,
          raw: item,
        };
      });
    });
    return { jobId, pages, dataInfo };
  }

  private parseDocParsingResult(jobId: string, jsonlData: unknown[]): DocParsingResult {
    const dataInfo: Record<string, unknown> = {};
    const pages = jsonlData.flatMap((lineObj) => {
      if (!isRecord(lineObj) || !isRecord(lineObj.result) || !Array.isArray(lineObj.result.layoutParsingResults)) {
        throw new ResultParseError("Document parsing result item is missing result.layoutParsingResults.");

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Retry the upload — connection resets are frequently transient
  2. Check proxy/body-size limits if uploads consistently die partway (nginx client_max_body_size equivalents)
  3. Shrink the file (compression, lower DPI) to shorten the transfer
  4. Move the file to object storage and use submit_url instead
  5. If persistent, test raw connectivity with curl -T file <endpoint>

Example fix

# retry helper
from paddleocr._api_client.errors import NetworkError
for attempt in range(3):
    try:
        job_id = client.submit_file(model, path, {})
        break
    except NetworkError:
        if attempt == 2:
            raise
Defensive patterns

Strategy: retry

Try / catch

from paddleocr._api_client.errors import NetworkError
for attempt in range(3):
    try:
        job_id = client.submit_file(model, file_path, {})
        break
    except NetworkError:
        time.sleep(2 ** attempt)
else:
    raise RuntimeError("Upload failed after retries")

Prevention

When it happens

Trigger: client.submit_file(...) over an unstable connection, through a proxy that kills long uploads, or with a firewall resetting large POSTs.

Common situations: Mobile/tethered networks; proxy body-size limits; VPN drops; cloud function egress restrictions; keepalive idle resets on slow uploads.

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/6dc507de48ac59c5. Report an issue: GitHub.