{"record":{"id":"1765767bc27afaa1","repo":"Tencent/WeKnora","slug":"mineru-cloud-apply-upload-urls-w","errorCode":null,"errorMessage":"MinerU Cloud apply upload URLs: %w","messagePattern":"MinerU Cloud apply upload URLs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/docparser/mineru_cloud_converter.go","lineNumber":81,"sourceCode":"\t}\n\n\tlogger.Infof(context.Background(), \"[MinerUCloud] Parsing file=%s size=%d via %s\", req.FileName, len(content), c.baseURL)\n\n\text := filepath.Ext(req.FileName)\n\tif ext == \"\" && req.FileType != \"\" {\n\t\text = \".\" + req.FileType\n\t}\n\tif ext == \"\" {\n\t\text = \".pdf\"\n\t}\n\tfileName := strings.TrimSuffix(req.FileName, ext) + ext\n\tif fileName == ext {\n\t\tfileName = \"document\" + ext\n\t}\n\n\tbatchID, uploadURL, err := c.applyUploadURLs(ctx, fileName, ext)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"MinerU Cloud apply upload URLs: %w\", err)\n\t}\n\n\tif err := c.uploadFile(ctx, uploadURL, content); err != nil {\n\t\treturn nil, fmt.Errorf(\"MinerU Cloud file upload: %w\", err)\n\t}\n\n\tmdContent, imageRefs, err := c.pollBatchResult(ctx, batchID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"MinerU Cloud poll: %w\", err)\n\t}\n\n\tmdContent, imageRefs = ensureOriginalImageRef(req, mdContent, imageRefs)\n\n\treturn &types.ReadResult{\n\t\tMarkdownContent: mdContent,\n\t\tImageRefs:       imageRefs,\n\t}, nil\n}","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/docparser/mineru_cloud_converter.go#L63-L99","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the wrapped cause for the HTTP status: fix the API key if 401/403 (verify the credentials env var).","Verify c.baseURL points at the correct MinerU Cloud endpoint and is reachable (curl the endpoint).","Confirm network egress/proxy/firewall allows HTTPS to the MinerU API host.","Retry on 429/5xx — the service may be rate limiting or temporarily down.","Check the request payload (fileName/ext) is acceptable to the API version you are calling."],"exampleFix":"// before\nclient := NewMinerUCloudConverter(baseURL: \"https://mineru.example-wrong.com\", apiKey: os.Getenv(\"MINERU_KEY\"))\n// after: correct endpoint + key present\nu := os.Getenv(\"MINERU_BASE_URL\") // https://mineru.net/api/v4\nk := os.Getenv(\"MINERU_API_KEY\")\nif u == \"\" || k == \"\" { return nil, errors.New(\"mineru base url/api key required\") }\nclient := NewMinerUCloudConverter(baseURL: u, apiKey: k)","handlingStrategy":"retry","validationCode":"if os.Getenv(\"MINERU_API_KEY\") == \"\" {\n    return errors.New(\"MINERU_API_KEY must be set before using MinerU Cloud converter\")\n}\nif _, err := url.Parse(baseURL); err != nil || baseURL == \"\" {\n    return fmt.Errorf(\"invalid MinerU baseURL %q\", baseURL)\n}","typeGuard":null,"tryCatchPattern":"res, err := converter.Read(ctx, req)\nif err != nil {\n    if strings.Contains(err.Error(), \"apply upload URLs\") {\n        var retriable = strings.Contains(err.Error(), \"429\") || strings.Contains(err.Error(), \"503\") || strings.Contains(err.Error(), \"timeout\")\n        if retriable {\n            return retryWithBackoff(ctx, 3, func() error { return readAgain(ctx, req) })\n        }\n        return fmt.Errorf(\"mineru apply-upload-urls failed (check API key/baseURL): %w\", err)\n    }\n    return err\n}","preventionTips":["Validate the API key and baseURL at service startup with a health/auth check call.","Apply exponential backoff for 429/5xx responses from the MinerU API.","Monitor the MinerU status page and set alerts on repeated applyUploadURLs failures.","Keep credentials in env/secret manager; rotate before expiry to avoid 401 storms."],"tags":["http","cloud-api","network","auth"],"backgroundTag":"cloud-api-request-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}