{"record":{"id":"afb6538872421541","repo":"fish2018/pansou","slug":"web-search-request-failed-w","errorCode":null,"errorMessage":"web search request failed: %w","messagePattern":"web search request failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/sousou/sousou.go","lineNumber":183,"sourceCode":"\tContent  string\n\tDiskType string\n\tDatetime time.Time\n\tPassword string\n}\n\nfunc (p *SousouAsyncPlugin) searchWeb(client *http.Client, keyword string) ([]model.SearchResult, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\tdefer cancel()\n\n\tsearchURL := SousouWebURL + \"?q=\" + url.QueryEscape(strings.TrimSpace(keyword))\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, searchURL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create web search request failed: %w\", err)\n\t}\n\tsetSousouWebHeaders(req, \"https://www.panso.vip/\")\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"web search request failed: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"web search returned status %d\", resp.StatusCode)\n\t}\n\n\tdoc, err := goquery.NewDocumentFromReader(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parse web search page failed: %w\", err)\n\t}\n\n\titems := make([]pansoSearchItem, 0, 20)\n\tdoc.Find(\"div.search-item\").Each(func(_ int, item *goquery.Selection) {\n\t\tanchor := item.Find(\"a.search-item-title[href]\").First()\n\t\thref := strings.TrimSpace(anchor.AttrOr(\"href\", \"\"))\n\t\tif href == \"\" {\n\t\t\treturn\n\t\t}","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/sousou/sousou.go#L165-L201","documentation":"After building the web search request, searchWeb executes it with client.Do. Any transport-level failure — DNS, connect, TLS, timeout, context deadline — is returned wrapped as 'web search request failed'. The 30-second context timeout surfaces here as well.","triggerScenarios":"client.Do(req) returns a non-nil error in searchWeb: network unreachable, TLS handshake failure, DNS failure, or the 30s context.WithTimeout expired mid-request.","commonSituations":"panso.vip blocked or slow from the host, no internet egress, corporate TLS proxy, site temporarily down, or heavy keyword causing a slow response past the 30s deadline.","solutions":["Check errors.Is(err, context.DeadlineExceeded) to distinguish timeout from connect failure.","Verify outbound network access and DNS resolution for www.panso.vip from the host.","Increase the 30s timeout if the site is consistently slow, or add retry with backoff.","Confirm the site is still reachable/upstream has not blocked your IP (test with curl)."],"exampleFix":"// before\nresp, err := client.Do(req)\nif err != nil {\n    return nil, fmt.Errorf(\"web search request failed: %w\", err)\n}\n// after\nresp, err := client.Do(req)\nif err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        return nil, fmt.Errorf(\"web search request timed out after 30s: %w\", err)\n    }\n    return nil, fmt.Errorf(\"web search request failed: %w\", err)\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(keyword)\nif err != nil && strings.Contains(err.Error(), \"web search request failed\") {\n    if errors.Is(errors.Unwrap(err), context.DeadlineExceeded) {\n        // timeout: retry with a longer deadline or skip source\n    } else {\n        // connectivity problem: check DNS/proxy/egress\n    }\n}","preventionTips":["Set timeouts appropriate to the slowest expected upstream","Distinguish timeout vs connection errors via errors.Is/As","Health-check source hosts before search fan-out","Use retries with jittered backoff for transient network faults"],"tags":["network","http","timeout","go"],"backgroundTag":"network-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"}