{"record":{"id":"0dff4670570256fa","repo":"sipeed/picoclaw","slug":"failed-to-get-qrcode-w","errorCode":null,"errorMessage":"failed to get qrcode: %w","messagePattern":"failed to get qrcode: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/weixin/auth.go","lineNumber":48,"sourceCode":"\t\topts.BaseURL = \"https://ilinkai.weixin.qq.com/\"\n\t}\n\tif opts.BotType == \"\" {\n\t\topts.BotType = \"3\" // Default iLink Bot Type\n\t}\n\tif opts.Timeout == 0 {\n\t\topts.Timeout = 5 * time.Minute\n\t}\n\n\tapi, err := NewApiClient(opts.BaseURL, \"\", opts.Proxy)\n\tif err != nil {\n\t\treturn \"\", \"\", \"\", \"\", fmt.Errorf(\"failed to create api client: %w\", err)\n\t}\n\tpollAPI := api\n\n\tlogger.InfoC(\"weixin\", \"Requesting Weixin QR code...\")\n\tqrResp, err := api.GetQRCode(ctx, opts.BotType)\n\tif err != nil {\n\t\treturn \"\", \"\", \"\", \"\", fmt.Errorf(\"failed to get qrcode: %w\", err)\n\t}\n\n\tfmt.Println(\"\\n=======================================================\")\n\tfmt.Println(\"Please scan the following QR code with WeChat to login:\")\n\tfmt.Println(\"=======================================================\")\n\tfmt.Println()\n\n\t// Create Small QR\n\tqrconfig := qrterminal.Config{\n\t\tLevel:      qrterminal.L,\n\t\tWriter:     os.Stdout,\n\t\tHalfBlocks: true,\n\t}\n\tqrterminal.GenerateWithConfig(qrResp.QrcodeImgContent, qrconfig)\n\n\tfmt.Printf(\"\\nQR Code Link: %s\\n\\n\", qrResp.QrcodeImgContent)\n\tfmt.Println(\"Waiting for scan...\")\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/weixin/auth.go#L30-L66","documentation":"The Weixin login flow requested a QR code from ilink/bot/get_bot_qrcode and the call failed: either a transport error (network down, DNS failure, TLS issue, proxy refused) or a non-200 response (error 667) from the iLink endpoint. The QR code is the entry point of the whole interactive login, so the flow aborts before printing anything to scan.","triggerScenarios":"GetQRCode (a GET to ilink/bot/get_bot_qrcode with bot_type, default \"3\") failing due to: no internet connectivity from the host, DNS for ilinkai.weixin.qq.com not resolving, a firewall blocking the endpoint, an invalid proxy, or the server returning 4xx/5xx.","commonSituations":"Running the login command in a container/sandbox without outbound network; corporate proxy required but not configured; Weixin iLink endpoint temporarily down or geo-blocked; typo'd custom BaseURL; system clock skew breaking TLS.","solutions":["Verify outbound reachability: curl https://ilinkai.weixin.qq.com/ from the same host/environment","If a proxy is required, set opts.Proxy correctly (and make sure it is well-formed, see error 666)","Re-run the login command — transient server errors resolve on retry","If a custom BaseURL was set, drop it and use the default","In containers, ensure DNS and CA certificates are functional (TLS handshake failure surfaces here)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// preflight connectivity before starting the interactive flow\nfunc reachable(ctx context.Context, base string) bool {\n    req, _ := http.NewRequestWithContext(ctx, http.MethodHead, base, nil)\n    resp, err := http.DefaultClient.Do(req)\n    if err != nil {\n        return false\n    }\n    defer resp.Body.Close()\n    return resp.StatusCode < 500\n}","typeGuard":"func isWeixinQRCodeFetchFail(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"failed to get qrcode\")\n}","tryCatchPattern":"var qrErr error\nfor attempt := 0; attempt < 3; attempt++ {\n    if _, _, _, _, qrErr = weixin.Login(ctx, opts); qrErr == nil || !isWeixinQRCodeFetchFail(qrErr) {\n        break\n    }\n    time.Sleep(2 * time.Second)\n}","preventionTips":["Preflight network/DNS to ilinkai.weixin.qq.com before launching login","Configure the proxy for the login command when the host requires one","Retry transient fetch failures — the QR is only minted on demand","Keep CA certificates current in containers to avoid TLS handshake failures"],"tags":["weixin","auth","network","login","qrcode"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}