{"record":{"id":"e8b94fef66fb23fb","repo":"fish2018/pansou","slug":"get-w-e8b94f","errorCode":null,"errorMessage":"GET请求失败: %w","messagePattern":"GET请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/qupanshe/qupanshe.go","lineNumber":158,"sourceCode":"// getFormhash 从首页获取真实的formhash值\nfunc (p *QupanshePlugin) getFormhash(client *http.Client) (string, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\tdefer cancel()\n\n\treq, err := http.NewRequestWithContext(ctx, \"GET\", BaseURL, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"创建GET请求失败: %w\", err)\n\t}\n\n\tp.setRequestHeaders(req)\n\n\tif DebugLog {\n\t\tfmt.Printf(\"[qupanshe] 请求首页获取formhash: %s\\n\", BaseURL)\n\t}\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"GET请求失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// 调试：显示从首页获取的cookies\n\tif DebugLog && client.Jar != nil {\n\t\tif u, _ := url.Parse(BaseURL); u != nil {\n\t\t\tcookies := client.Jar.Cookies(u)\n\t\t\tfmt.Printf(\"[qupanshe] 从首页获取到 %d 个cookies:\\n\", len(cookies))\n\t\t\tfor i, cookie := range cookies {\n\t\t\t\tfmt.Printf(\"  Cookie[%d]: %s=%s\\n\", i, cookie.Name, cookie.Value)\n\t\t\t}\n\t\t}\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"首页请求返回状态码: %d\", resp.StatusCode)\n\t}\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/qupanshe/qupanshe.go#L140-L176","documentation":"getFormhash wraps a failure from client.Do when executing the GET request to the homepage. This is a transport-level failure: the request never completed with an HTTP response, so formhash extraction cannot proceed.","triggerScenarios":"client.Do(req) returns an error during Step 1: DNS failure, connection refused/reset, TLS errors, request timeout (15s context or client.Timeout), or proxy failures.","commonSituations":"Site unreachable or offline, DNS misconfiguration, corporate proxy/firewall blocking, TLS certificate problems, or slow site exceeding the 15-second context timeout.","solutions":["Test connectivity to BaseURL (curl/ping) from the same host","Check DNS and proxy environment variables (HTTP_PROXY/HTTPS_PROXY)","Increase the 15s context timeout if the site is slow","Verify TLS: update system CA pool or handle certificate issues","Add retry with backoff for transient network errors"],"exampleFix":"// before\nctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n// after\nctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)","handlingStrategy":"retry","validationCode":"// pre-flight: confirm host reachable\nconn, err := net.DialTimeout(\"tcp\", host+\":80\", 3*time.Second)\nif err != nil { /* skip search: network down */ } else { conn.Close() }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"GET请求失败\") {\n    var ne net.Error\n    if errors.As(err, &ne) && ne.Timeout() {\n        // retry with longer timeout\n    }\n}","preventionTips":["Check proxy env vars are correct for the host","Use timeouts generous enough for slow sites","Add retry with exponential backoff","Monitor DNS/TLS health on the deployment host"],"tags":["go","network","http-client","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"}