{"record":{"id":"74768ac13b1b3390","repo":"chenhg5/cc-connect","slug":"http-d-s","errorCode":null,"errorMessage":"http %d: %s","messagePattern":"http (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/weixin.go","lineNumber":411,"sourceCode":"\tclient := &http.Client{Timeout: weixinQRPollTimeout + 5*time.Second}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tbody, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif debug {\n\t\tsnippet := string(body)\n\t\tif len(snippet) > 200 {\n\t\t\tsnippet = snippet[:200]\n\t\t}\n\t\tfmt.Fprintf(os.Stderr, \"[debug] GET %s -> %d %s\\n\", fullURL, resp.StatusCode, strings.TrimSpace(snippet))\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"http %d: %s\", resp.StatusCode, weixinTruncateBody(body, 256))\n\t}\n\treturn body, nil\n}\n\nfunc weixinTruncateBody(b []byte, max int) string {\n\ts := string(b)\n\tif len(s) <= max {\n\t\treturn s\n\t}\n\treturn s[:max] + \"…\"\n}\n\nfunc weixinFetchBotQRCode(ctx context.Context, apiBase, botType, routeTag string, debug bool) (*weixinBotQRResponse, error) {\n\tbase := strings.TrimRight(apiBase, \"/\") + \"/\"\n\tu, err := url.Parse(base)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/weixin.go#L393-L429","documentation":"weixinHTTPGet is the shared HTTP GET helper for the WeChat ilink setup flow. When the server responds with any status code other than 200 OK, it discards the body as a success payload and returns this error embedding the numeric status and a truncated (256-char) response body so the underlying API failure reason is visible to the caller.","triggerScenarios":"Any weixin setup HTTP call (e.g. weixinFetchBotQRCode fetching get_bot_qrcode) receiving a non-200 status such as 401 (invalid route/token), 403, 429 (rate limit), or 5xx from the ilink API endpoint.","commonSituations":"Wrong or stale API base URL configured; corporate proxy or firewall returning an error page; ilink service outage or rate limiting; region/route tag mismatch causing server rejection.","solutions":["Read the embedded status code and body snippet to identify the server-side reason","Verify the weixin api_base URL in your config is correct and reachable (curl it directly)","Retry later if the status is 429 or 5xx — the service may be rate limiting or down","Check proxy/firewall settings if the body shows a gateway or proxy error page"],"exampleFix":"// before (blind retry on any URL)\nraw, err := weixinHTTPGet(ctx, \"https://wrong-host/ilink/bot/get_bot_qrcode\", ...)\n// after (verify endpoint first)\nif u.Host != \"correct-ilink-host\" { return nil, fmt.Errorf(\"weixin: unexpected api base %s\", u.Host) }\nraw, err := weixinHTTPGet(ctx, u.String(), ...)","handlingStrategy":"try-catch","validationCode":"resp, err := http.Get(apiBase + \"/ilink/bot/get_bot_qrcode?bot_type=...\")\nif err != nil || resp.StatusCode != http.StatusOK {\n    return fmt.Errorf(\"weixin api unreachable: status=%v err=%v\", statusOf(resp), err)\n}","typeGuard":null,"tryCatchPattern":"raw, err := weixinHTTPGet(ctx, u, routeTag, debug)\nvar httpErr *weixinHTTPError\nif errors.As(err, &httpErr) {\n    switch {\n    case httpErr.Status == 429 || httpErr.Status >= 500:\n        // backoff and retry\n    default:\n        // fail fast with body snippet\n    }\n}","preventionTips":["Validate api_base with curl before running setup","Watch for 429/5xx and apply backoff rather than tight retries","Check proxy/firewall configuration in restricted networks","Keep route tags and endpoints consistent with your region"],"tags":["http","network","weixin","api"],"backgroundTag":"http-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}