Tencent/WeKnora · error

MinerU Cloud apply upload URLs

Error message

MinerU Cloud apply upload URLs: %w

What it means

Read in the MinerU Cloud converter first calls applyUploadURLs to request presigned upload URLs from the MinerU service (POST /file-urls/batch); any failure there is wrapped as "MinerU Cloud apply upload URLs: %w". This is the initial handshake with the cloud service, so failures usually mean connectivity, auth, or API problems before any file is uploaded.

Solutions

  1. Check the wrapped cause for the HTTP status: fix the API key if 401/403 (verify the credentials env var).
  2. Verify c.baseURL points at the correct MinerU Cloud endpoint and is reachable (curl the endpoint).
  3. Confirm network egress/proxy/firewall allows HTTPS to the MinerU API host.
  4. Retry on 429/5xx — the service may be rate limiting or temporarily down.
  5. Check the request payload (fileName/ext) is acceptable to the API version you are calling.

Example fix

// before
client := NewMinerUCloudConverter(baseURL: "https://mineru.example-wrong.com", apiKey: os.Getenv("MINERU_KEY"))
// after: correct endpoint + key present
u := os.Getenv("MINERU_BASE_URL") // https://mineru.net/api/v4
k := os.Getenv("MINERU_API_KEY")
if u == "" || k == "" { return nil, errors.New("mineru base url/api key required") }
client := NewMinerUCloudConverter(baseURL: u, apiKey: k)
Defensive patterns

Strategy: retry

Validate before calling

if os.Getenv("MINERU_API_KEY") == "" {
    return errors.New("MINERU_API_KEY must be set before using MinerU Cloud converter")
}
if _, err := url.Parse(baseURL); err != nil || baseURL == "" {
    return fmt.Errorf("invalid MinerU baseURL %q", baseURL)
}

Try / catch

res, err := converter.Read(ctx, req)
if err != nil {
    if strings.Contains(err.Error(), "apply upload URLs") {
        var retriable = strings.Contains(err.Error(), "429") || strings.Contains(err.Error(), "503") || strings.Contains(err.Error(), "timeout")
        if retriable {
            return retryWithBackoff(ctx, 3, func() error { return readAgain(ctx, req) })
        }
        return fmt.Errorf("mineru apply-upload-urls failed (check API key/baseURL): %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Read -> applyUploadURLs returned an error: HTTP request to baseURL/file-urls/batch failed, returned a non-2xx status, or the response body could not be decoded into the expected upload-URL structure.

Common situations: Invalid or expired MINERU API key (401/403); wrong baseURL or region endpoint; network egress blocked/proxy required; MinerU service outage or rate limiting; unsupported file extension passed in the batch payload.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/1765767bc27afaa1. Report an issue: GitHub.

Appendix: source

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

	}

	logger.Infof(context.Background(), "[MinerUCloud] Parsing file=%s size=%d via %s", req.FileName, len(content), c.baseURL)

	ext := filepath.Ext(req.FileName)
	if ext == "" && req.FileType != "" {
		ext = "." + req.FileType
	}
	if ext == "" {
		ext = ".pdf"
	}
	fileName := strings.TrimSuffix(req.FileName, ext) + ext
	if fileName == ext {
		fileName = "document" + ext
	}

	batchID, uploadURL, err := c.applyUploadURLs(ctx, fileName, ext)
	if err != nil {
		return nil, fmt.Errorf("MinerU Cloud apply upload URLs: %w", err)
	}

	if err := c.uploadFile(ctx, uploadURL, content); err != nil {
		return nil, fmt.Errorf("MinerU Cloud file upload: %w", err)
	}

	mdContent, imageRefs, err := c.pollBatchResult(ctx, batchID)
	if err != nil {
		return nil, fmt.Errorf("MinerU Cloud poll: %w", err)
	}

	mdContent, imageRefs = ensureOriginalImageRef(req, mdContent, imageRefs)

	return &types.ReadResult{
		MarkdownContent: mdContent,
		ImageRefs:       imageRefs,
	}, nil
}

View on GitHub (pinned to 988cbb0330)