chenhg5/cc-connect · error

empty qrcode_img_content from server

Error message

empty qrcode_img_content from server

What it means

runWeixinQRLoginFlow fetches a login QR code from the WeChat/ilink bot server via weixinFetchBotQRCode. Even on success, the server may return a payload whose qrcode_img_content is blank; the code rejects it with "empty qrcode_img_content from server" because there is no URL to render or poll against. This indicates a malformed or degraded server response rather than a client-side mistake.

Source

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

	IlinkUserID string
}

func runWeixinQRLoginFlow(opts weixinQRLoginOptions) (*weixinQRLoginResult, error) {
	if opts.Timeout < time.Second {
		opts.Timeout = 480 * time.Second
	}
	botType := opts.BotType
	if botType == "" {
		botType = defaultWeixinBotType
	}

	ctx := context.Background()
	qrPayload, err := weixinFetchBotQRCode(ctx, opts.APIBaseURL, botType, opts.RouteTag, opts.Debug)
	if err != nil {
		return nil, err
	}
	if strings.TrimSpace(qrPayload.QRCodeImgContent) == "" {
		return nil, fmt.Errorf("empty qrcode_img_content from server")
	}

	qrURL := strings.TrimSpace(qrPayload.QRCodeImgContent)
	fmt.Println("请使用微信扫描下方二维码(或打开 URL)以连接 ilink 机器人:")
	fmt.Printf("URL: %s\n\n", qrURL)
	tryPrintTerminalQRCode(qrURL)
	if opts.QRImage != "" {
		if err := saveQRCodeImage(qrURL, opts.QRImage); err != nil {
			fmt.Fprintf(os.Stderr, "Warning: failed to save QR image: %v\n", err)
		} else {
			fmt.Printf("QR code saved to: %s\n\n", opts.QRImage)
		}
	}

	deadline := time.Now().Add(opts.Timeout)
	qrKey := qrPayload.QRCode
	refreshCount := 1
	scannedPrinted := false

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Simply retry `cc-connect weixin setup` — transient backend issues often resolve on a second attempt.
  2. Verify --api-base-url / APIBaseURL points at the correct production endpoint.
  3. Enable debug mode (opts.Debug) or inspect the raw HTTP response to confirm what the server returned.
  4. Check the weixin/ilink service status or changelog for API contract changes to qrcode_img_content.
  5. If persisting, report the issue with the request/response captured in debug output.

Example fix

// before (trust any 200)
qrPayload, err := weixinFetchBotQRCode(ctx, opts.APIBaseURL, ...)
if err != nil { return nil, err }

// after (guard empties with retry)
for attempt := 0; attempt < 3; attempt++ {
    qrPayload, err := weixinFetchBotQRCode(ctx, opts.APIBaseURL, ...)
    if err == nil && strings.TrimSpace(qrPayload.QRCodeImgContent) != "" {
        break
    }
    time.Sleep(2 * time.Second)
}
Defensive patterns

Strategy: retry

Validate before calling

qr, err := weixinFetchBotQRCode(ctx, apiBase, botType, routeTag, debug)
if err == nil && strings.TrimSpace(qr.QRCodeImgContent) == "" {
    // treat as retryable upstream error before starting the poll loop
}

Try / catch

qrPayload, err := runWeixinQRLoginFlow(ctx, opts)
if err != nil && strings.Contains(err.Error(), "empty qrcode_img_content") {
    time.Sleep(2 * time.Second)
    qrPayload, err = runWeixinQRLoginFlow(ctx, opts) // one retry
}

Prevention

When it happens

Trigger: `cc-connect weixin setup` in new/QR mode → runWeixinQRLoginFlow → weixinFetchBotQRCode returns success (no transport error) but qrPayload.QRCodeImgContent is empty or whitespace-only after TrimSpace.

Common situations: WeChat/ilink backend incident or maintenance returning 200 with an empty body; wrong APIBaseURL pointing at a stub/mock server; API contract change after a server upgrade; rate limiting that silently empties the QR payload.

Understand the failure class

Background: "empty response", "returned no data", "empty embeddings": what HTTP 200-with-empty-body errors mean across libraries — this error's family across 36 libraries.

Related errors


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