{"record":{"id":"e9e9bf1666586e11","repo":"fish2018/pansou","slug":"w-e9e9bf","errorCode":null,"errorMessage":"备用域名请求也失败: %w","messagePattern":"备用域名请求也失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/panwiki/panwiki.go","lineNumber":193,"sourceCode":"\tif err != nil {\n\t\t// 如果主域名失败，尝试切换到备用域名\n\t\tif p.currentBaseURL == PrimaryBaseURL {\n\t\t\tif p.debugMode {\n\t\t\t\tlog.Printf(\"[Panwiki] 主域名请求失败，尝试备用域名: %v\", err)\n\t\t\t}\n\t\t\tp.switchToBackupDomain()\n\t\t\t\n\t\t\t// 重新构建URL并重试\n\t\t\tinitialURL = p.getSearchURL(keyword, page)\n\t\t\treq, err = http.NewRequest(\"GET\", initialURL, nil)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"创建备用域名请求失败: %w\", err)\n\t\t\t}\n\t\t\tp.setRequestHeaders(req)\n\t\t\t\n\t\t\tresp, err = client.Do(req)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"备用域名请求也失败: %w\", err)\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"初始请求失败: %w\", err)\n\t\t}\n\t}\n\tdefer resp.Body.Close()\n\t\n\t// 重置重定向策略\n\tclient.CheckRedirect = nil\n\t\n\t// 获取重定向URL\n\tlocation := resp.Header.Get(\"Location\")\n\tif location == \"\" {\n\t\treturn nil, fmt.Errorf(\"未获取到重定向URL\")\n\t}\n\t\n\t// 构建完整的重定向URL\n\tvar searchURL string","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/panwiki/panwiki.go#L175-L211","documentation":"searchPage in the panwiki plugin issues a GET to the primary search URL with redirects disabled. If that transport fails and the plugin has already switched to the backup domain (or the backup retry also fails at the transport level), it wraps the underlying error with \"备用域名请求也失败\" — meaning both the primary and backup domain requests could not complete (DNS, TLS, timeout, connection reset).","triggerScenarios":"client.Do on the rebuilt backup-domain URL returns a non-nil error — e.g. the backup domain is unreachable, DNS fails, TLS handshake fails, request times out, or the network is down. Only fires when the primary request already failed and p.currentBaseURL was PrimaryBaseURL so switchToBackupDomain was attempted.","commonSituations":"Both panwiki domains blocked or down (e.g. GFW/network filtering), offline environment, DNS resolver misconfiguration, corporate proxy blocking outbound HTTPS, overly short client timeout.","solutions":["Verify network connectivity and DNS resolution for both the primary and backup panwiki domains (curl the base URLs).","Check the wrapped %w error to identify whether it is DNS, TLS, or timeout and fix that specific cause.","Increase the http.Client timeout if it is too aggressive.","Configure/verify the backup domain is correct and currently serving; if the site moved, update PrimaryBaseURL/backup constants.","Add a proxy configuration if the environment requires one for outbound requests."],"exampleFix":"// before\nresp, err = client.Do(req)\nif err != nil {\n    return nil, fmt.Errorf(\"备用域名请求也失败: %w\", err)\n}\n// after\nresp, err = client.Do(req)\nif err != nil {\n    log.Printf(\"panwiki: backup domain request failed: %v\", err)\n    return nil, fmt.Errorf(\"备用域名请求也失败: %w\", err) // caller should inspect errors.Unwrap for cause\n}","handlingStrategy":"retry","validationCode":"// Go: preflight reachability check\nfunc reachable(u string) bool {\n    c := &http.Client{Timeout: 5 * time.Second}\n    resp, err := c.Head(u)\n    return err == nil && resp.StatusCode < 500\n}","typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(keyword, page)\nif err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) && netErr.Timeout() {\n        // retry with backoff or serve cached results\n    }\n    return fmt.Errorf(\"search unavailable: %w\", err)\n}","preventionTips":["Monitor both primary and backup domain availability.","Set realistic client timeouts (not too short).","Configure a proxy for restricted networks.","Keep backup domains current — verify they still resolve and serve.","Cache last-known-good results to degrade gracefully."],"tags":["network","http","go","scraping"],"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"}