Tencent/WeKnora · error

PUT upload: %w

Error message

PUT upload: %w

What it means

Transport error in MinerUCloudReader.uploadFile: the SSRF-safe client's Do() for the PUT upload of the document bytes failed. The %w wraps the network/storage-side cause (timeout, connection reset); raised after the PUT request was built, before the response status check.

Source

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

	}
	if len(result.Data.FileURLs) == 0 {
		return "", "", fmt.Errorf("API returned no file_urls")
	}

	logger.Infof(context.Background(), "[MinerUCloud] batch apply ok: batch_id=%s, urls=%d", result.Data.BatchID, len(result.Data.FileURLs))
	return result.Data.BatchID, result.Data.FileURLs[0], nil
}

func (c *MinerUCloudReader) uploadFile(ctx context.Context, uploadURL string, content []byte) error {
	httpReq, err := http.NewRequestWithContext(ctx, http.MethodPut, uploadURL, bytes.NewReader(content))
	if err != nil {
		return fmt.Errorf("create PUT request: %w", err)
	}

	client := utils.NewSSRFSafeHTTPClient(utils.SSRFSafeHTTPClientConfig{Timeout: 120 * time.Second, MaxRedirects: 5})
	resp, err := client.Do(httpReq)
	if err != nil {
		return fmt.Errorf("PUT upload: %w", err)
	}
	resp.Body.Close()

	if resp.StatusCode >= 300 {
		return fmt.Errorf("PUT upload status %d", resp.StatusCode)
	}
	logger.Infof(context.Background(), "[MinerUCloud] file uploaded, status=%d", resp.StatusCode)
	return nil
}

// --- polling ---

type batchPollResponse struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data struct {
		ExtractResult json.RawMessage `json:"extract_result"` // can be object or array
	} `json:"data"`

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Retry the upload; large files on flaky networks are the usual cause
  2. Check egress bandwidth and the 120s timeout adequacy
  3. Re-apply for upload URLs if the pre-signed URL expired
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/infrastructure/docparser/mineru_cloud_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/55574294c260c17f. Report an issue: GitHub.