{"record":{"id":"81463fb1101c1a2c","repo":"sipeed/picoclaw","slug":"login-failed-w-81463f","errorCode":null,"errorMessage":"login failed: %w","messagePattern":"login failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/auth/weixin.go","lineNumber":56,"sourceCode":"\tcmd.Flags().IntVar(&timeout, \"timeout\", 300, \"Login timeout in seconds\")\n\n\treturn cmd\n}\n\nfunc runWeixinOnboard(baseURL, proxy string, timeout time.Duration) error {\n\tfmt.Println(\"Starting Weixin (WeChat personal) login...\")\n\tfmt.Println()\n\n\tbotToken, userID, accountID, returnedBaseURL, err := weixin.PerformLoginInteractive(\n\t\tcontext.Background(),\n\t\tweixin.AuthFlowOpts{\n\t\t\tBaseURL: baseURL,\n\t\t\tTimeout: timeout,\n\t\t\tProxy:   proxy,\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"login failed: %w\", err)\n\t}\n\n\tfmt.Println()\n\tfmt.Println(\"✅ Login successful!\")\n\tfmt.Printf(\"   Account ID : %s\\n\", accountID)\n\tif userID != \"\" {\n\t\tfmt.Printf(\"   User ID    : %s\\n\", userID)\n\t}\n\tfmt.Println()\n\n\t// Prefer the server-returned base URL (may be region-specific)\n\teffectiveBaseURL := returnedBaseURL\n\tif effectiveBaseURL == \"\" {\n\t\teffectiveBaseURL = baseURL\n\t}\n\n\tif err := saveWeixinConfig(botToken, effectiveBaseURL, proxy); err != nil {\n\t\tfmt.Printf(\"⚠️  Could not auto-save to config: %v\\n\", err)","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/auth/weixin.go#L38-L74","documentation":"Top-level wrapper for any failure in weixin.PerformLoginInteractive (pkg/channels/weixin/auth.go:25), the WeChat-personal QR login flow. Underlying causes visible through %w: 'failed to create api client' (bad BaseURL/proxy), 'failed to get qrcode' (initial HTTP call to ilinkai.weixin.qq.com), or 'login timeout' (default 5-minute scan deadline exceeded).","triggerScenarios":"Custom BaseURL or proxy that breaks the API client; GetQRCode HTTP failure against https://ilinkai.weixin.qq.com/; user not scanning/confirming within opts.Timeout (default 5m); network drop during the 2-second-interval status polling.","commonSituations":"User starts weixin login and does not scan in 5 minutes; wrong region blocking WeChat login servers; proxy env vars misconfigured; typo'd --base-url flag.","solutions":["Unwrap the cause: 'login timeout' means re-run and scan within the window; 'failed to get qrcode' means network/endpoint trouble","Verify https://ilinkai.weixin.qq.com/ is reachable from your network (curl)","Remove or fix proxy settings (HTTP_PROXY/HTTPS_PROXY) and any custom --base-url","Increase the timeout option for slow interactive environments and retry","On mobile/VPN networks that block WeChat domains, switch networks before logging in"],"exampleFix":"// before\nif err != nil {\n\treturn fmt.Errorf(\"login failed: %w\", err)\n}\n\n// after: give an actionable hint for the most common cause\nif err != nil {\n\tif strings.Contains(err.Error(), \"login timeout\") {\n\t\treturn fmt.Errorf(\"login failed: QR code was not confirmed within the timeout — re-run and scan+confirm in WeChat promptly: %w\", err)\n\t}\n\treturn fmt.Errorf(\"login failed (check network/proxy and retry): %w\", err)\n}","handlingStrategy":"retry","validationCode":"// Validate custom endpoints before starting the interactive flow\nif baseURL != \"\" {\n\tif _, err := url.Parse(baseURL); err != nil {\n\t\treturn fmt.Errorf(\"invalid --base-url %q: %w\", baseURL, err)\n\t}\n}","typeGuard":"func isLoginTimeout(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"login timeout\")\n}","tryCatchPattern":"botToken, userID, accountID, returnedBaseURL, err := weixin.PerformLoginInteractive(ctx, opts)\nif err != nil {\n\tif isLoginTimeout(err) {\n\t\t// re-run flow and instruct user to scan+confirm promptly\n\t}\n\treturn fmt.Errorf(\"login failed: %w\", err)\n}","preventionTips":["Have WeChat ready to scan before invoking login; default window is 5 minutes","Clear or correct proxy env vars and custom BaseURL settings","Raise opts.Timeout in scripted or demo environments"],"tags":["go","weixin","wechat","qr-code","network"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}