{"record":{"id":"4e512b1246afe66c","repo":"fish2018/pansou","slug":"request-failed-page-d-w","errorCode":null,"errorMessage":"request failed (page %d): %w","messagePattern":"request failed \\(page (.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/hunhepan/hunhepan.go","lineNumber":236,"sourceCode":"\t\t\treq.Header.Set(\"Accept-Language\", \"zh-CN,zh;q=0.9,en;q=0.8\")\n\n\t\t\t// 根据不同的API设置不同的Referer\n\t\t\tif strings.Contains(apiURL, \"qkpanso.com\") {\n\t\t\t\treq.Header.Set(\"Referer\", \"https://qkpanso.com/search\")\n\t\t\t} else if strings.Contains(apiURL, \"kuake8.com\") {\n\t\t\t\treq.Header.Set(\"Referer\", \"https://kuake8.com/search\")\n\t\t\t} else if strings.Contains(apiURL, \"hunhepan.com\") {\n\t\t\t\treq.Header.Set(\"Referer\", \"https://hunhepan.com/search\")\n\t\t\t} else if strings.Contains(apiURL, \"misoso.cc\") {\n\t\t\t\treq.Header.Set(\"Referer\", \"https://www.misoso.cc/search\")\n\t\t\t\treq.Header.Set(\"Origin\", \"https://www.misoso.cc\")\n\t\t\t}\n\n\t\t\t// 发送请求\n\t\t\tresp, err := client.Do(req)\n\t\t\tif err != nil {\n\t\t\t\tdebugLog(\"请求失败 (page %d): %v\", pageNum, err)\n\t\t\t\terrChan <- fmt.Errorf(\"request failed (page %d): %w\", pageNum, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefer resp.Body.Close()\n\n\t\t\tdebugLog(\"收到响应 (page %d), 状态码: %d\", pageNum, resp.StatusCode)\n\n\t\t\t// 读取响应体\n\t\t\trespBody, err := io.ReadAll(resp.Body)\n\t\t\tif err != nil {\n\t\t\t\tdebugLog(\"读取响应失败 (page %d): %v\", pageNum, err)\n\t\t\t\terrChan <- fmt.Errorf(\"read response body failed (page %d): %w\", pageNum, err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tdebugLog(\"响应内容 (page %d, 前500字符): %s\", pageNum, string(respBody[:min(500, len(respBody))]))\n\n\t\t\t// 解析响应\n\t\t\tvar apiResp HunhepanResponse","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/hunhepan/hunhepan.go#L218-L254","documentation":"Hunhepan plugin's paginated search issues this error when http.Client.Do fails for a given page and wraps the original *url.Error. The goroutine sends the wrapped error to errChan and stops processing that page. It is an outbound HTTP transport failure, not an API-level error.","triggerScenarios":"client.Do(req) returns a non-nil error for page pageNum: DNS resolution failure, connection refused/reset, TLS handshake error, or the per-request context deadline (defaultTimeout) is exceeded before a response is received.","commonSituations":"The upstream hunhepan API host is down or blocked; DNS cannot resolve the domain; the machine has no network; the timeout is too short for slow responses; a proxy/firewall drops the connection.","solutions":["Verify network connectivity and DNS resolution for the API host (curl the search URL manually).","Increase the plugin's defaultTimeout since slow upstream responses abort the request context.","Check for proxy/firewall/VPN interference; set HTTPS_PROXY if the environment requires one.","Retry the search; failures here are wrapped per page so check which pageNum failed."],"exampleFix":"// before\nresp, err := client.Do(req)\nif err != nil {\n\terrChan <- fmt.Errorf(\"request failed (page %d): %w\", pageNum, err)\n\treturn\n}\n// after\nresp, err := client.Do(req)\nif err != nil {\n\tvar netErr net.Error\n\tif errors.As(err, &netErr) && netErr.Timeout() {\n\t\terrChan <- fmt.Errorf(\"request timed out (page %d): %w\", pageNum, err)\n\t} else {\n\t\terrChan <- fmt.Errorf(\"request failed (page %d): %w\", pageNum, err)\n\t}\n\treturn\n}","handlingStrategy":"retry","validationCode":"// before calling the plugin\nu, err := url.Parse(apiBaseURL)\nif err != nil || u.Host == \"\" {\n\treturn fmt.Errorf(\"hunhepan API base URL invalid: %w\", err)\n}\nif _, err := net.LookupHost(u.Hostname()); err != nil {\n\treturn fmt.Errorf(\"cannot resolve hunhepan host %s: %w\", u.Hostname(), err)\n}","typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(ctx, keyword)\nif err != nil {\n\tvar netErr net.Error\n\tif errors.As(err, &netErr) && netErr.Timeout() {\n\t\t// retry with a longer timeout or skip this source\n\t}\n\tlog.Printf(\"hunhepan page fetch failed, skipping source: %v\", err)\n}","preventionTips":["Set a realistic timeout that tolerates slow upstream APIs","Verify DNS/connectivity to the API host before deployment","Configure proxy settings explicitly when running behind a firewall","Monitor per-source failures and degrade gracefully instead of failing the whole search"],"tags":["network","http","go","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"}