{"record":{"id":"9a09ada0c32259ad","repo":"fish2018/pansou","slug":"w-9a09ad","errorCode":null,"errorMessage":"请求二维码失败: %w","messagePattern":"请求二维码失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/qqpd/qqpd.go","lineNumber":2081,"sourceCode":"\t\treturn uin[:4] + \"****\" + uin[len(uin)-2:]\n\t}\n\treturn uin[:2] + \"****\" + uin[len(uin)-2:]\n}\n\n// generateQRCodeWithSig 生成QQ登录二维码并返回qrsig\nfunc (p *QQPDPlugin) generateQRCodeWithSig() ([]byte, string, error) {\n\tqrcodeURL := \"https://xui.ptlogin2.qq.com/ssl/ptqrshow?appid=1600001587&e=2&l=M&s=3&d=72&v=4&t=0.3680011491059967&daid=823&pt_3rd_aid=0\"\n\n\tclient := &http.Client{\n\t\tTimeout: 15 * time.Second,\n\t\tTransport: &http.Transport{\n\t\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\n\t\t},\n\t}\n\n\tresp, err := client.Get(qrcodeURL)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"请求二维码失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\treturn nil, \"\", fmt.Errorf(\"二维码请求返回状态码: %d\", resp.StatusCode)\n\t}\n\n\t// 读取二维码图片\n\tqrcodeBytes, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"读取二维码失败: %w\", err)\n\t}\n\n\t// 提取qrsig（用于后续登录检测）\n\tsetCookie := resp.Header.Get(\"Set-Cookie\")\n\tqrsig := extractQrsig(setCookie)\n\tif qrsig != \"\" && DebugLog {\n\t\tfmt.Printf(\"[QQPD] 二维码生成成功，qrsig: %s\\n\", qrsig[:20]+\"...\")","sourceCodeStart":2063,"sourceCodeEnd":2099,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/qqpd/qqpd.go#L2063-L2099","documentation":"generateQRCodeWithSig (plugin/qqpd/qqpd.go:2081) performs client.Get(qrcodeURL) to download the QR code image; any transport failure is wrapped as '请求二维码失败: %w'. Called from handleGetStatus and handleRefreshQRCode, this error means the QR image could not be fetched from QQ's qrcode endpoint over an http.Client configured with InsecureSkipVerify TLS.","triggerScenarios":"handleGetStatus or handleRefreshQRCode triggers QR generation; client.Get fails with a DNS error, connection refused/timeout, TLS handshake failure, or proxy error before a response is received.","commonSituations":"Host has no outbound internet access or DNS failure, a corporate proxy blocking ssl.ptlogin2.qq.com, transient network flaps, or firewall egress rules in containerized deployments.","solutions":["Check the wrapped cause to identify DNS vs timeout vs connection refused","Verify outbound connectivity: curl -v the qrcode URL from the deployment host","Add or honor proxy configuration if the environment requires one","Implement a retry with backoff for transient network failures when generating the QR code"],"exampleFix":"// before\nresp, err := client.Get(qrcodeURL)\nif err != nil {\n    return nil, \"\", fmt.Errorf(\"请求二维码失败: %w\", err)\n}\n// after\nvar resp *http.Response\nfor attempt := 0; attempt < 3; attempt++ {\n    resp, err = client.Get(qrcodeURL)\n    if err == nil {\n        break\n    }\n    time.Sleep(time.Duration(attempt+1) * 200 * time.Millisecond)\n}\nif err != nil {\n    return nil, \"\", fmt.Errorf(\"请求二维码失败: %w\", err)\n}","handlingStrategy":"retry","validationCode":"// probe reachability before generating the QR code\nconn, err := net.DialTimeout(\"tcp\", \"ssl.ptlogin2.qq.com:443\", 3*time.Second)\nif err != nil {\n    return fmt.Errorf(\"cannot reach QQ qrcode host: %w\", err)\n}\nconn.Close()","typeGuard":null,"tryCatchPattern":"img, _, err := p.generateQRCodeWithSig(sig)\nif err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) && netErr.Timeout() {\n        // transient; retry QR generation after backoff\n    }\n    return err\n}","preventionTips":["Verify egress/DNS to QQ's qrcode host from the deployment environment","Configure proxy support if running behind a corporate firewall","Retry QR generation with backoff on transient network errors","Prefer honoring system proxy/TLS settings over a hardcoded InsecureSkipVerify client"],"tags":["network","http","qr-code"],"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"}