{"record":{"id":"f077cf3ff30d9730","repo":"fish2018/pansou","slug":"s-search-request-failed-on-page-d-w-f077cf","errorCode":null,"errorMessage":"[%s] search request failed on page %d: %w","messagePattern":"\\[(.+?)\\] search request failed on page (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/panzun/panzun.go","lineNumber":126,"sourceCode":"func (p *PanzunPlugin) searchImpl(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {\n\tif p.scraper == nil {\n\t\treturn nil, fmt.Errorf(\"cloudscraper not initialized\")\n\t}\n\n\tvar allResults []model.SearchResult\n\tseenIDs := make(map[string]bool)\n\n\tfor page := 1; page <= maxPages; page++ {\n\t\toffset := (page - 1) * pageSize\n\t\tsearchURL := fmt.Sprintf(\"%s/discussions?filter[q]=%s&page[offset]=%d\", apiBase, url.QueryEscape(keyword), offset)\n\n\t\tresp, err := p.scraper.Get(searchURL)\n\t\tif err != nil {\n\t\t\tif len(allResults) > 0 {\n\t\t\t\tfmt.Printf(\"[%s] Warning: failed to fetch page %d: %v\\n\", p.Name(), page, err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"[%s] search request failed on page %d: %w\", p.Name(), page, err)\n\t\t}\n\n\t\tif resp.StatusCode != http.StatusOK {\n\t\t\tresp.Body.Close()\n\t\t\tif len(allResults) > 0 {\n\t\t\t\tfmt.Printf(\"[%s] Warning: unexpected status code %d on page %d\\n\", p.Name(), resp.StatusCode, page)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"[%s] unexpected status code: %d on page %d\", p.Name(), resp.StatusCode, page)\n\t\t}\n\n\t\tbody, err := io.ReadAll(resp.Body)\n\t\tresp.Body.Close()\n\t\tif err != nil {\n\t\t\tif len(allResults) > 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"[%s] failed to read response on page %d: %w\", p.Name(), page, err)","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/panzun/panzun.go#L108-L144","documentation":"p.scraper.Get(searchURL) failed with a transport-level error on a search page. When no results have been collected yet (allResults empty) the error is fatal and wrapped with page number and plugin name; if earlier pages succeeded, the loop just breaks with a warning since partial results are usable.","triggerScenarios":"Network failure, DNS failure, TLS error, connection timeout, or Cloudflare challenge failure while GETting https://www.panzun.cc/api/discussions?filter[q]=... on page N, with zero results collected so far.","commonSituations":"Target site down or blocking the client IP; no network access in the deployment environment; Cloudflare protection rejecting the cloudscraper handshake; timeout too low for a slow upstream.","solutions":["Check basic connectivity to panzun.cc from the host (curl the API URL)","Retry later or increase the HTTP client timeout","Inspect the wrapped %w cause for the underlying transport error (DNS/TLS/timeout)","If Cloudflare blocks the request, update the cloudscraper client or use a proxy"],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"[%s] search request failed on page %d: %w\", p.Name(), page, err)\n// after\nif urlErr, ok := err.(*url.Error); ok { log.Printf(\"transport error: %v\", urlErr.Err) }\nreturn nil, fmt.Errorf(\"[%s] search request failed on page %d: %w\", p.Name(), page, err) // inspect wrapped cause","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"www.panzun.cc:443\", 5*time.Second)\nif err != nil { /* upstream unreachable — skip plugin */ } else { conn.Close() }","typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(keyword, ext)\nif err != nil {\n    var urlErr *url.Error\n    if errors.As(err, &urlErr) && urlErr.Timeout() {\n        // transient: retry with backoff\n    } else {\n        // skip this plugin, use other providers\n    }\n}","preventionTips":["Monitor upstream availability and skip plugins whose source is down","Set realistic HTTP timeouts and retry budgets","Use the wrapped %w error to classify DNS vs timeout vs TLS failures"],"tags":["go","network","http","scraping","plugin"],"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"}