{"record":{"id":"b36524d41523d068","repo":"fish2018/pansou","slug":"w-b36524","errorCode":null,"errorMessage":"详情页请求失败: %w","messagePattern":"详情页请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/wuji/wuji.go","lineNumber":317,"sourceCode":"\t\t}\n\t}\n\t// 创建带超时的上下文\n\tctx, cancel := context.WithTimeout(context.Background(), TimeoutSeconds*time.Second)\n\tdefer cancel()\n\t\n\t// 创建请求\n\treq, err := http.NewRequestWithContext(ctx, \"GET\", detailURL, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"创建详情页请求失败: %w\", err)\n\t}\n\t\n\t// 设置请求头\n\tp.setRequestHeaders(req)\n\t\n\t// 发送HTTP请求\n\tresp, err := p.doRequestWithRetry(req, client)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"详情页请求失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\t\n\t// 检查状态码\n\tif resp.StatusCode != 200 {\n\t\treturn \"\", fmt.Errorf(\"详情页返回状态码: %d\", resp.StatusCode)\n\t}\n\t\n\t// 读取响应体内容\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"读取详情页响应失败: %w\", err)\n\t}\n\t\n\t// 解析HTML\n\tdoc, err := goquery.NewDocumentFromReader(strings.NewReader(string(body)))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"详情页HTML解析失败: %w\", err)","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/wuji/wuji.go#L299-L335","documentation":"fetchMagnetLink sends the detail-page GET request through doRequestWithRetry, which retries client.Do up to MaxRetries with linear backoff. This error wraps the last transport-level failure after all retries are exhausted: DNS failure, connection refused/reset, TLS errors, or the per-request timeout context expiring.","triggerScenarios":"All MaxRetries attempts of client.Do on the detail-page request fail — site unreachable, TLS handshake failure, connection reset, or the TimeoutSeconds context deadline exceeded. The wrapped error is doRequestWithRetry's '请求失败，已重试%d次' error.","commonSituations":"The wuji detail site is down or blocked from the deployment region; no outbound internet in the container; corporate proxy/firewall dropping HTTPS; the site changed domains; the context timeout is too short for a slow site.","solutions":["Unwrap with errors.Unwrap / %w chain and check for context.DeadlineExceeded vs connection errors to distinguish timeout from unreachability.","Increase TimeoutSeconds if the detail page is slow but reachable (test with curl from the same host).","Verify network egress from the deployment environment (DNS resolution, proxy env vars HTTPS_PROXY).","Check whether the site's domain changed and update the plugin's base URL configuration.","Ensure the HTTP client has appropriate proxy/TLS settings if operating behind a firewall."],"exampleFix":"// before\nif _, err := p.fetchMagnetLink(client, detailURL); err != nil {\n    log.Fatal(err)\n}\n// after\nif _, err := p.fetchMagnetLink(client, detailURL); err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        log.Printf(\"detail page timed out, skipping: %s\", detailURL)\n    } else {\n        log.Printf(\"detail page unreachable, skipping: %s (%v)\", detailURL, err)\n    }\n}","handlingStrategy":"retry","validationCode":"// optional pre-check\nresp, err := http.Head(detailURL)\nif err != nil { /* host unreachable; skip enrichment for this URL */ }","typeGuard":null,"tryCatchPattern":"magnet, err := p.fetchMagnetLink(client, detailURL)\nif err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        log.Printf(\"timeout fetching %s\", detailURL)\n    }\n    return \"\" // degrade gracefully\n}","preventionTips":["Right-size TimeoutSeconds for the slowest realistic page","Keep MaxRetries with backoff enabled for flaky targets","Verify egress/proxy config in deployment environments","Monitor for site domain changes and update the base URL promptly"],"tags":["network","http","retry","timeout"],"backgroundTag":"http-request-failed","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}