{"record":{"id":"5527ab775022514a","repo":"Tencent/WeKnora","slug":"extract-zip-w","errorCode":null,"errorMessage":"extract zip: %w","messagePattern":"extract zip: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/docparser/mineru_cloud_converter.go","lineNumber":344,"sourceCode":"\treturn items, nil\n}\n\n// extractDoneResult extracts markdown and images from a completed batch item.\n// Prefers inline markdown/content fields; falls back to downloading full_zip_url.\nfunc (c *MinerUCloudReader) extractDoneResult(_ context.Context, item *extractResultItem) (string, []types.ImageRef, error) {\n\ttext := firstNonEmpty(item.Markdown, item.Content, item.Text)\n\tif text != \"\" {\n\t\tlogger.Infof(context.Background(), \"[MinerUCloud] parsed (inline), length=%d\", len(text))\n\t\treturn text, nil, nil\n\t}\n\n\tif item.FullZipURL == \"\" {\n\t\treturn \"\", nil, fmt.Errorf(\"MinerU Cloud state=done but no markdown/content or full_zip_url\")\n\t}\n\n\tmd, imageRefs, err := downloadAndExtractZip(item.FullZipURL)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"extract zip: %w\", err)\n\t}\n\n\tlogger.Infof(context.Background(), \"[MinerUCloud] parsed (zip), markdown=%d chars, images=%d\", len(md), len(imageRefs))\n\treturn md, imageRefs, nil\n}\n\n// --- ZIP handling ---\n\nvar imgRefPattern = regexp.MustCompile(`!\\[[^\\]]*\\]\\(([^)]+)\\)`)\n\nfunc downloadAndExtractZip(zipURL string) (string, []types.ImageRef, error) {\n\tif err := utils.ValidateURLForSSRF(zipURL); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"zip URL blocked by SSRF check: %v\", err)\n\t}\n\tclient := utils.NewSSRFSafeHTTPClient(utils.SSRFSafeHTTPClientConfig{Timeout: 120 * time.Second, MaxRedirects: 5})\n\tresp, err := client.Get(zipURL)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"download zip: %w\", err)","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/docparser/mineru_cloud_converter.go#L326-L362","documentation":"The MinerU Cloud result ZIP (pointed to by full_zip_url) failed to download or unpack inside downloadAndExtractZip, and extractDoneResult wraps the failure as 'extract zip: %w' (mineru_cloud_converter.go:344). The wrapped cause may itself be the SSRF-check error, download error, status error, read error, or a zip extraction error. Only the result delivery step failed — parsing itself succeeded server-side.","triggerScenarios":"extractDoneResult downloads item.FullZipURL and downloadAndExtractZip returns any error: SSRF validation rejection, HTTP GET failure, non-200 status, body read failure, or corrupt/unreadable ZIP content.","commonSituations":"Expired result download URLs (MinerU Cloud presigned links expire); large ZIPs exceeding the 120s client timeout on slow links; corporate proxies blocking the storage host; zip lacking the expected markdown file layout.","solutions":["Unwrap the error to find which inner step failed (SSRF, download, status, read, or zip format) and address that specifically.","Retry promptly after task completion if the URL may have expired; re-run the batch to get a fresh full_zip_url.","Increase the 120s timeout or improve network access for very large ZIPs.","Ensure the ZIP contains the expected markdown/content files; verify MinerU Cloud output layout."],"exampleFix":"// before\nmd, imageRefs, err := downloadAndExtractZip(item.FullZipURL)\nif err != nil {\n    return \"\", nil, fmt.Errorf(\"extract zip: %w\", err)\n}\n// after — one bounded retry for transient failures\nmd, imageRefs, err := downloadAndExtractZip(item.FullZipURL)\nif err != nil {\n    time.Sleep(2 * time.Second)\n    md, imageRefs, err = downloadAndExtractZip(item.FullZipURL)\n    if err != nil {\n        return \"\", nil, fmt.Errorf(\"extract zip: %w\", err)\n    }\n}","handlingStrategy":"retry","validationCode":"u, err := url.Parse(item.FullZipURL)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") || u.Host == \"\" {\n    return errors.New(\"invalid full_zip_url\")\n}","typeGuard":null,"tryCatchPattern":"var md string\nvar images []types.ImageRef\nvar err error\nfor attempt := 0; attempt < 3; attempt++ {\n    md, images, err = pollBatchResult(ctx, batchID)\n    if err == nil || !strings.Contains(err.Error(), \"extract zip:\") {\n        break\n    }\n    time.Sleep(time.Duration(attempt+1) * 2 * time.Second)\n}\nif err != nil {\n    return err\n}","preventionTips":["Unwrap the error to distinguish SSRF/download/status/read/zip-format causes before acting.","Apply bounded retries for transient download failures.","Size the HTTP timeout to your largest expected ZIP (the default is 120s)."],"tags":["zip","download","network","go","file-processing"],"backgroundTag":"zip-download-extraction-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}