chenhg5/cc-connect · error

login confirmed but ilink_bot_id missing

Error message

login confirmed but ilink_bot_id missing

What it means

On "confirmed" poll status the login succeeded on WeChat's side, and runWeixinQRLoginFlow expects the server to hand back the bot identity. If status.IlinkBotID is blank it returns "login confirmed but ilink_bot_id missing" — the auth handshake completed but the response payload lacks the required bot identifier, so no usable credentials can be produced.

Source

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

			newURL := strings.TrimSpace(newQR.QRCodeImgContent)
			if newURL != "" {
				fmt.Println("请扫描新二维码:")
				fmt.Printf("URL: %s\n\n", newURL)
				tryPrintTerminalQRCode(newURL)
			}
			// 过期刷新时同步更新 QR 图片文件
			if opts.QRImage != "" {
				if err := saveQRCodeImage(newURL, opts.QRImage); err != nil {
					fmt.Fprintf(os.Stderr, "Warning: failed to update QR image: %v\n", err)
				} else {
					fmt.Printf("QR code updated at: %s\n\n", opts.QRImage)
				}
			}
			time.Sleep(time.Second)
			continue
		case "confirmed":
			if strings.TrimSpace(status.IlinkBotID) == "" {
				return nil, fmt.Errorf("login confirmed but ilink_bot_id missing")
			}
			if strings.TrimSpace(status.BotToken) == "" {
				return nil, fmt.Errorf("login confirmed but bot_token missing")
			}
			fmt.Println("\n✅ 已与微信建立连接。")
			return &weixinQRLoginResult{
				BotToken:    strings.TrimSpace(status.BotToken),
				IlinkBotID:  strings.TrimSpace(status.IlinkBotID),
				BaseURL:     strings.TrimSpace(status.BaseURL),
				IlinkUserID: strings.TrimSpace(status.IlinkUserID),
			}, nil
		default:
			time.Sleep(time.Second)
		}
	}

	return nil, fmt.Errorf("等待扫码超时,请重试")
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Retry `cc-connect weixin setup` — a server-side glitch may be transient.
  2. Capture the confirmed status response (debug mode) and check whether ilink_bot_id is present under a different key (API drift).
  3. Verify APIBaseURL targets the current production API version; update client if the schema changed.
  4. Confirm the WeChat account actually completed bot provisioning on the ilink platform.
  5. Fall back to `cc-connect weixin bind --token ...` with a manually obtained token.

Example fix

// before: hard fail on missing field
if strings.TrimSpace(status.IlinkBotID) == "" {
    return nil, fmt.Errorf("login confirmed but ilink_bot_id missing")
}

// after: log payload for diagnosis before failing
if strings.TrimSpace(status.IlinkBotID) == "" {
    slog.Error("weixin: confirmed status missing ilink_bot_id", "status", status)
    return nil, fmt.Errorf("login confirmed but ilink_bot_id missing")
}
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate the confirmed status shape before consuming:
if status.Status == "confirmed" && strings.TrimSpace(status.IlinkBotID) == "" {
    slog.Warn("server returned confirmed without ilink_bot_id; retrying")
}

Type guard

func hasBotID(s *pollStatus) bool {
    return s != nil && strings.TrimSpace(s.IlinkBotID) != ""
}

Try / catch

res, err := runWeixinQRLoginFlow(ctx, opts)
if err != nil && strings.Contains(err.Error(), "ilink_bot_id missing") {
    // upstream returned incomplete payload; retry or bind manually
    return fmt.Errorf("server sent incomplete login result; try again or use bind --token")
}

Prevention

When it happens

Trigger: `cc-connect weixin setup` QR flow reaches case "confirmed" in the poll loop, strings.TrimSpace(status.IlinkBotID) == "" — the status endpoint returned confirmed without ilink_bot_id.

Common situations: ilink backend bug or partial deployment omitting the field; API schema change renaming ilink_bot_id; account in a state where the bot was never fully provisioned despite login; mocked/stub APIBaseURL returning minimal payloads.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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