Tencent/WeKnora · error
task failed: %s
Error message
task failed: %s
What it means
The remote PaddleOCR VL parsing task transitioned to state="failed" and pollJob surfaces the provider's ErrorMsg verbatim. The error text after the prefix comes from the cloud service, not from this library, so diagnosis must use the embedded provider message. pollJob returns this to Read, which fails the whole document parse.
Source
Thrown at internal/infrastructure/docparser/paddleocr_vl_cloud_converter.go:242
logger.Errorf(context.Background(), "[PaddleOCR-VL Cloud] poll #%d decode error: %v", pollCount, err)
sleepCtx(ctx, paddleOCRVLCloudPollInterval)
continue
}
state := strings.ToLower(pollResp.Data.State)
if pollCount == 1 || pollCount%6 == 0 || state == "done" || state == "failed" {
logger.Infof(context.Background(), "[PaddleOCR-VL Cloud] poll #%d: state=%s pages=%d/%d",
pollCount, state, pollResp.Data.ExtractProgress.ExtractedPages, pollResp.Data.ExtractProgress.TotalPages)
}
switch state {
case "done":
if pollResp.Data.ResultURL.JSONURL == "" {
return "", fmt.Errorf("state=done but no jsonUrl")
}
return pollResp.Data.ResultURL.JSONURL, nil
case "failed":
return "", fmt.Errorf("task failed: %s", pollResp.Data.ErrorMsg)
}
sleepCtx(ctx, paddleOCRVLCloudPollInterval)
}
return "", fmt.Errorf("task timed out after %d polls", pollCount)
}
// --- result parsing ---
type paddleOCRVLCloudResultLine struct {
Result struct {
LayoutParsingResults []struct {
Markdown struct {
Text string `json:"text"`
Images map[string]string `json:"images"`
} `json:"markdown"`
} `json:"layoutParsingResults"`View on GitHub (pinned to 988cbb0330)
Solutions
- Read the embedded ErrorMsg in the error string and address the provider-specific cause (bad file, quota, unsupported format).
- Re-encode/re-upload the document (e.g. re-save the PDF, strip encryption, reduce size/pages).
- Retry Read — transient provider worker failures usually succeed on resubmission.
- Verify API credentials and account quota with the PaddleOCR cloud service.
- If the file is reliably rejected, pre-validate the document locally or fall back to a local OCR parser.
Example fix
// before
if err := task.SubmitAndPoll(ctx, doc); err != nil {
return err // task failed: <provider msg>
}
// after
if err := task.SubmitAndPoll(ctx, doc); err != nil {
if strings.Contains(err.Error(), "task failed:") {
return fmt.Errorf("cloud OCR rejected document (%v); check file format/size or retry", err)
}
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-validate the document before submitting to the cloud service
func validForCloudOCR(file *os.File) error {
st, err := file.Stat()
if err != nil { return err }
if st.Size() > 50<<20 { return errors.New("file exceeds cloud OCR size limit") }
return nil
} Try / catch
err := reader.Read(ctx, file)
var providerMsg string
if err != nil && strings.HasPrefix(err.Error(), "task failed: ") {
providerMsg = strings.TrimPrefix(err.Error(), "task failed: ")
// route providerMsg to logs/alerts and decide retry vs permanent failure
} Prevention
- Pre-check document format, encryption, page count, and size against provider limits.
- Surface the embedded provider ErrorMsg to your own logs for actionable diagnosis.
- Classify provider messages into retryable vs permanent before auto-retrying.
- Verify API credentials and quota in CI/deploy checks.
When it happens
Trigger: pollJob polls a submitted task and pollResp.Data.State == "failed"; the provider's pollResp.Data.ErrorMsg is wrapped into "task failed: %s" and returned to Read.
Common situations: Unsupported or corrupted document uploaded (encrypted PDF, scanned images over size limits); document exceeds provider page/size quota; transient GPU/worker failure on the provider side; invalid API token causing task rejection reported asynchronously.
Related errors
- state=done but no jsonUrl
- task timed out after %d polls
- jsonl URL blocked by SSRF check: %v
- anydoc scanned-PDF fallback returned no result for %q
- download jsonl: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/113fa27fde0b235e.
Report an issue: GitHub.