{"record":{"id":"a6250cce1b26ba7a","repo":"Tencent/WeKnora","slug":"http-request-w-a6250c","errorCode":null,"errorMessage":"HTTP request: %w","messagePattern":"HTTP request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/docparser/mineru_converter.go","lineNumber":248,"sourceCode":"\t}\n\tif _, err := part.Write(content); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"write file content: %w\", err)\n\t}\n\twriter.Close()\n\n\thttpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, c.endpoint+\"/file_parse\", &body)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"create request: %w\", err)\n\t}\n\thttpReq.Header.Set(\"Content-Type\", writer.FormDataContentType())\n\n\tclient := utils.NewSSRFSafeHTTPClient(utils.SSRFSafeHTTPClientConfig{\n\t\tTimeout:      mineruTimeout,\n\t\tMaxRedirects: 5,\n\t})\n\tresp, err := client.Do(httpReq)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"HTTP request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\trespBody, _ := io.ReadAll(resp.Body)\n\t\treturn \"\", nil, fmt.Errorf(\"MinerU API status %d: %s\", resp.StatusCode, string(respBody))\n\t}\n\n\trespBody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"read response body: %w\", err)\n\t}\n\n\t// Dump raw response for debugging (truncate if too large)\n\trawStr := string(respBody)\n\tif len(rawStr) > 4000 {\n\t\tlogger.Infof(context.Background(), \"[MinerU] Raw response (truncated to 4000 chars): %s ...\", rawStr[:4000])\n\t} else {","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/docparser/mineru_converter.go#L230-L266","documentation":"The SSRF-safe HTTP client failed to execute the POST to MinerU's /file_parse endpoint. This wraps transport-level failures: DNS resolution errors, connection refused/reset, TLS errors, timeouts, or blocked redirects — not an HTTP error status (non-200 produces the separate 'MinerU API status' error).","triggerScenarios":"client.Do(httpReq) returns a *url.Error: endpoint host unresolvable, connection refused (service down/wrong port), TLS certificate failure, mineruTimeout exceeded, or context canceled mid-request.","commonSituations":"MinerU container not running or on a different host/port than configured; DNS not resolving inside Kubernetes/Docker network; self-signed certificates without proper trust; document too large so the request exceeds mineruTimeout.","solutions":["Unwrap the cause and check errors.Is(err, context.DeadlineExceeded) vs connection-refused to distinguish timeout vs unreachable host.","Verify MinerU is up and the endpoint host:port is correct and reachable (curl http://<endpoint>/file_parse or a health route).","If timeouts dominate, increase mineruTimeout or run parsing asynchronously with a longer budget.","Check the SSRF-safe client's allowlist — private/internal MinerU hosts may be blocked by the SSRF guard; adjust its config.","Fix TLS trust (add CA to the trust store) if the error is a certificate verification failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"doc, err := conv.Read(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"HTTP request\") {\n    var netErr net.Error\n    if errors.As(err, &netErr) && netErr.Timeout() || errors.Is(err, context.DeadlineExceeded) {\n        return fmt.Errorf(\"mineru timed out, requeue job: %w\", err) // retry/async\n    }\n    if errors.Is(err, syscall.ECONNREFUSED) {\n        return fmt.Errorf(\"mineru unreachable, check service/endpoint: %w\", err)\n    }\n    return err\n}","preventionTips":["Health-check the MinerU service before dispatching parse jobs","Distinguish timeouts (retry/async) from connection-refused (alert/fix config)","Tune mineruTimeout to document sizes and monitor p99 parse durations","Verify the SSRF-safe client allowlist includes your MinerU host","Use k8s/docker DNS names and readiness probes for the MinerU dependency"],"tags":["network","http","timeout","dns","mineru"],"backgroundTag":"connection-refused","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}