{"record":{"id":"7193021536e97ae3","repo":"fish2018/pansou","slug":"w-719302","errorCode":null,"errorMessage":"搜索请求失败: %w","messagePattern":"搜索请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/xb6v/xb6v.go","lineNumber":182,"sourceCode":"\n\tif p.debugMode {\n\t\tlog.Printf(\"[Xb6v] 开始搜索: %s (原始: %s)\", keyword, originalKeyword)\n\t}\n\n\t// 第一步：POST搜索请求\n\tsearchURL := p.currentBase + SearchPath\n\tpostData := fmt.Sprintf(\"show=title&tempid=1&tbname=article&mid=1&dopost=search&submit=&keyboard=%s\", url.QueryEscape(keyword))\n\n\t// 创建不自动重定向的客户端\n\tnoRedirectClient := &http.Client{\n\t\tCheckRedirect: func(req *http.Request, via []*http.Request) error {\n\t\t\treturn http.ErrUseLastResponse\n\t\t},\n\t}\n\n\tresp, err := p.doRequest(noRedirectClient, \"POST\", searchURL, postData, p.currentBase)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"搜索请求失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif p.debugMode {\n\t\tlog.Printf(\"[Xb6v] POST响应状态码: %d\", resp.StatusCode)\n\t}\n\n\t// 获取重定向的location\n\tlocation := resp.Header.Get(\"Location\")\n\tif p.debugMode {\n\t\tlog.Printf(\"[Xb6v] Location头: '%s'\", location)\n\t}\n\n\t// 如果没有Location头，可能需要从响应体中解析\n\tif location == \"\" {\n\t\tif p.debugMode {\n\t\t\tlog.Printf(\"[Xb6v] 未找到Location头，尝试解析响应体\")\n\t\t}","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/xb6v/xb6v.go#L164-L200","documentation":"xb6v's searchImpl POSTs the search form through p.doRequest using a no-redirect client (CheckRedirect returns http.ErrUseLastResponse) and wraps any transport failure as this error. It fires when the POST itself fails — DNS, connect, TLS, or timeout — before any response is available.","triggerScenarios":"p.doRequest(noRedirectClient, \"POST\", searchURL, postData, p.currentBase) returns an error: searchURL (currentBase + SearchPath) unreachable, domain changed, TLS failure, connection refused, or request timeout. Note it is not triggered by non-2xx responses — those are returned normally.","commonSituations":"The xb6v site changing its domain (p.currentBase stale) so the host no longer resolves; the site blocking the plugin's requests entirely; no network egress from the deployment environment; timeouts on a slow/overloaded site.","solutions":["Unwrap the error and check for DNS errors (e.g. 'no such host') — if present, the site domain changed and currentBase must be updated (run the plugin's base-discovery/fallback logic if available).","Verify network egress/DNS from the runtime environment (curl the search URL).","Confirm the search URL is built correctly (log searchURL) and includes no stale protocol/host.","Increase timeouts / enable retries in doRequest if the site is slow.","Configure proxy support if the site is blocked from your region."],"exampleFix":"// before\nresp, err := p.doRequest(noRedirectClient, \"POST\", searchURL, postData, p.currentBase)\nif err != nil {\n    return nil, fmt.Errorf(\"搜索请求失败: %w\", err)\n}\n// after\nresp, err := p.doRequest(noRedirectClient, \"POST\", searchURL, postData, p.currentBase)\nif err != nil {\n    if strings.Contains(err.Error(), \"no such host\") {\n        if rerr := p.refreshBaseURL(); rerr == nil {\n            return p.searchImpl(keyword)\n        }\n    }\n    return nil, fmt.Errorf(\"搜索请求失败: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// verify the configured base is reachable before searching\nresp, err := http.Get(p.currentBase)\nif err != nil { /* refresh base URL or report site down */ }","typeGuard":null,"tryCatchPattern":"results, err := p.search(keyword)\nif err != nil && strings.Contains(err.Error(), \"搜索请求失败\") {\n    if strings.Contains(err.Error(), \"no such host\") {\n        // domain likely changed; attempt base-url refresh\n    }\n    return nil, err\n}","preventionTips":["Keep base-URL discovery/fallback logic to survive domain changes","Check DNS egress from the deployment environment","Log the full searchURL when requests fail","Add proxy support for blocked regions"],"tags":["network","http","search","scraping"],"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"}