{"record":{"id":"dba30820a87e08b2","repo":"fish2018/pansou","slug":"s-w-dba308","errorCode":null,"errorMessage":"[%s] 搜索请求失败: %w","messagePattern":"\\[(.+?)\\] 搜索请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/djgou/djgou.go","lineNumber":140,"sourceCode":"\t// 3. 创建请求\n\treq, err := http.NewRequestWithContext(ctx, \"GET\", searchURL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 创建请求失败: %w\", p.Name(), err)\n\t}\n\n\t// 4. 设置完整的请求头（避免反爬虫）\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36\")\n\treq.Header.Set(\"Accept\", \"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8\")\n\treq.Header.Set(\"Accept-Language\", \"zh-CN,zh;q=0.9,en;q=0.8\")\n\treq.Header.Set(\"Connection\", \"keep-alive\")\n\treq.Header.Set(\"Upgrade-Insecure-Requests\", \"1\")\n\treq.Header.Set(\"Cache-Control\", \"max-age=0\")\n\treq.Header.Set(\"Referer\", SiteURL)\n\n\t// 5. 发送请求（带重试机制）\n\tresp, err := p.doRequestWithRetry(req, client)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求失败: %w\", p.Name(), err)\n\t}\n\n\tif resp.StatusCode != 200 {\n\t\tresp.Body.Close()\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求返回状态码: %d\", p.Name(), resp.StatusCode)\n\t}\n\n\t// 6. 读取并解析搜索结果页面。部分节点先返回 BTWAF JS 跳转页。\n\tbody, err := io.ReadAll(resp.Body)\n\tresp.Body.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 读取搜索页面失败: %w\", p.Name(), err)\n\t}\n\tdoc, err := goquery.NewDocumentFromReader(strings.NewReader(string(body)))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 解析搜索页面失败: %w\", p.Name(), err)\n\t}\n\tif doc.Find(\"article.post-item-row\").Length() == 0 {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/djgou/djgou.go#L122-L158","documentation":"The djgou plugin wraps any failure from its HTTP request retry loop (doRequestWithRetry) into a Chinese-language error meaning '[plugin] search request failed'. This library throws it when the site cannot be reached after all retries — DNS failure, timeout, TLS error, connection refused, or a request that never yields a response object. It preserves the underlying cause via %w.","triggerScenarios":"p.doRequestWithRetry(req, client) returns err != nil during searchImpl: all retry attempts fail at the transport level (connection refused, timeout, TLS handshake, context deadline).","commonSituations":"Target site (djgou) is down or blocking the host; no outbound network/DNS in the container; corporate proxy required but not configured; site IP changed; overly tight client timeout.","solutions":["Test basic reachability of the site: curl -I the SiteURL from the same host","Check DNS/proxy environment (HTTP_PROXY/HTTPS_PROXY) and container egress rules","Retry later or raise client/timeout settings if the site is intermittently slow","Inspect the wrapped cause (%w) with errors.Unwrap/As(*url.Error) to identify the transport failure"],"exampleFix":"// before\nitems, err := p.searchImpl(keyword)\nif err != nil { return err }\n// after\nitems, err := p.searchImpl(keyword)\nvar urlErr *url.Error\nif errors.As(err, &urlErr) && errors.Is(urlErr.Err, context.DeadlineExceeded) {\n    return fmt.Errorf(\"site timed out, retry later: %w\", err)\n}\nreturn err","handlingStrategy":"retry","validationCode":"func siteReachable(siteURL string) error {\n    ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n    defer cancel()\n    req, _ := http.NewRequestWithContext(ctx, http.MethodGet, siteURL, nil)\n    resp, err := http.DefaultClient.Do(req)\n    if err != nil { return err }\n    resp.Body.Close()\n    return nil\n}","typeGuard":null,"tryCatchPattern":"items, err := p.searchImpl(keyword)\nvar urlErr *url.Error\nif errors.As(err, &urlErr) {\n    log.Printf(\"djgou transport error: %v (timeout=%v)\", urlErr.Err, errors.Is(urlErr.Err, context.DeadlineExceeded))\n    // schedule retry with backoff\n}","preventionTips":["Pre-check site reachability before batch searches","Configure proxy env vars in restricted networks","Use generous client timeouts and exponential backoff","Monitor DNS/IP changes of the target site"],"tags":["network","http","search"],"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"}