chenhg5/cc-connect · error

get_qrcode_status http %d: %s

Error message

get_qrcode_status http %d: %s

What it means

weixinPollQRStatus polls `get_qrcode_status` while waiting for the user to scan the login QR code. On any non-200 HTTP status it returns this error with the status code and a truncated (256-char) body. A single occurrence is often transient; runWeixinQRLoginFlow treats it as a fatal poll failure unless the caller tolerates it.

Source

Thrown at cmd/cc-connect/weixin.go:492

		if errors.As(err, &ne) && ne.Timeout() {
			return &weixinQRStatusResponse{Status: "wait"}, nil
		}
		return nil, err
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
	if err != nil {
		return nil, err
	}
	if debug {
		snippet := string(body)
		if len(snippet) > 200 {
			snippet = snippet[:200]
		}
		fmt.Fprintf(os.Stderr, "[debug] poll status -> %d %s\n", resp.StatusCode, strings.TrimSpace(snippet))
	}
	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("get_qrcode_status http %d: %s", resp.StatusCode, weixinTruncateBody(body, 256))
	}
	var out weixinQRStatusResponse
	if err := json.Unmarshal(body, &out); err != nil {
		return nil, fmt.Errorf("get_qrcode_status json: %w", err)
	}
	return &out, nil
}

func verifyWeixinToken(ctx context.Context, apiBase, token, routeTag string, debug bool) error {
	base := strings.TrimRight(apiBase, "/") + "/"
	u := strings.TrimRight(base, "/") + "/ilink/bot/getupdates"
	body := []byte(`{"get_updates_buf":"","base_info":{"channel_version":"cc-connect-weixin-setup/1.0"}}`)
	req, err := http.NewRequestWithContext(ctx, http.MethodPost, u, bytes.NewReader(body))
	if err != nil {
		return err
	}
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("AuthorizationType", "ilink_bot_token")

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Retry the whole QR login flow to get a fresh qrKey (keys are short-lived)
  2. If status is 429, back off — reduce polling frequency or wait before retrying
  3. Check the body snippet for an expired/invalid-key message and regenerate the QR code
  4. Verify network/proxy stability for 5xx or gateway errors
Defensive patterns

Strategy: retry

Try / catch

st, err := weixinPollQRStatus(ctx, apiBase, qrKey, routeTag, debug)
if err != nil {
    if isRetryablePollErr(err) { // e.g. 429/5xx in message
        time.Sleep(backoff); continue
    }
    if strings.Contains(err.Error(), "expired") { regenerate QR and restart flow }
    return err
}

Prevention

When it happens

Trigger: Polling `ilink/bot/get_qrcode_status` with a qrKey that the server rejects (expired or invalid key), rate limiting (429), or a server error (5xx) during the scan-wait loop.

Common situations: QR key expired because the user took too long to scan; server-side throttling from aggressive polling; temporary ilink outage; wrong route tag causing rejection.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/cb932bd9fd9698aa. Report an issue: GitHub.