{"record":{"id":"c9f4c1110b584359","repo":"fish2018/pansou","slug":"w-c9f4c1","errorCode":null,"errorMessage":"初始请求失败: %w","messagePattern":"初始请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/panwiki/panwiki.go","lineNumber":196,"sourceCode":"\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\n\tif strings.HasPrefix(location, \"http\") {\n\t\tsearchURL = location\n\t} else {","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/panwiki/panwiki.go#L178-L214","documentation":"searchPage disables automatic redirects and expects the first response to be a redirect. If the FIRST request to the primary domain fails at the transport level while p.currentBaseURL is NOT the primary domain (i.e. the plugin is already on the backup domain), there is no second domain to fall back to, so it returns \"初始请求失败\" wrapping the client.Do error.","triggerScenarios":"client.Do(req) on the initial search URL returns an error AND p.currentBaseURL != PrimaryBaseURL (the plugin is already using the backup domain), so the else branch executes. Causes: DNS failure, timeout, TLS errors, connection refused against the backup domain.","commonSituations":"Backup domain itself is down or blocked; persistent outage after an earlier failover; network offline; DNS cannot resolve the backup domain.","solutions":["Inspect the wrapped error (errors.Unwrap) to identify the transport failure cause.","Check reachability of the current base URL with curl/ping.","Reset or restart the plugin to retry the primary domain if it has recovered.","Increase client timeout or configure a proxy if the network path requires it."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Go: verify the current base URL resolves before searching\nif net.ParseIP(\"\") == nil {\n    if _, err := net.LookupHost(strings.TrimPrefix(p.currentBaseURL, \"https://\")); err != nil {\n        return nil, fmt.Errorf(\"current base URL unreachable: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(keyword, page)\nif err != nil {\n    if strings.Contains(err.Error(), \"初始请求失败\") {\n        // fall back to another data source or serve cached results\n    }\n    return err\n}","preventionTips":["Alert when the plugin is pinned to the backup domain (it can no longer fail over).","Periodically probe the primary domain to allow fail-back.","Set generous but bounded timeouts.","Keep DNS healthy in the deployment environment."],"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"}