chenhg5/cc-connect · error
login confirmed but bot_token missing
Error message
login confirmed but bot_token missing
What it means
Immediately after the ilink_bot_id check, the "confirmed" branch validates status.BotToken. A confirmed login without a bot_token cannot authenticate future API calls, so runWeixinQRLoginFlow fails with "login confirmed but bot_token missing". Like the ilink_bot_id error, this points to an incomplete server response rather than user error.
Source
Thrown at cmd/cc-connect/weixin.go:368
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("等待扫码超时,请重试")
}
func weixinHTTPGet(ctx context.Context, fullURL, routeTag string, debug bool) ([]byte, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fullURL, nil)View on GitHub (pinned to 4000b2338a)
Solutions
- Retry `cc-connect weixin setup`; token issuance failures are often transient.
- Inspect the confirmed status payload in debug output to confirm the field name/shape hasn't changed.
- Verify APIBaseURL points at the correct, current ilink API endpoint.
- Check the account's bot status on the ilink platform — token issuance may be blocked for it.
- Use `cc-connect weixin bind --token ...` with a token obtained directly from the console as a workaround.
Example fix
// before
if strings.TrimSpace(status.BotToken) == "" {
return nil, fmt.Errorf("login confirmed but bot_token missing")
}
// after: also accept alternate field name from newer API versions
tok := strings.TrimSpace(status.BotToken)
if tok == "" { tok = strings.TrimSpace(status.Token) }
if tok == "" {
return nil, fmt.Errorf("login confirmed but bot_token missing")
} Defensive patterns
Strategy: type-guard
Validate before calling
// Validate the confirmed status carries a token before consuming:
if status.Status == "confirmed" && strings.TrimSpace(status.BotToken) == "" {
slog.Warn("server returned confirmed without bot_token; retrying")
} Type guard
func hasBotToken(s *pollStatus) bool {
return s != nil && strings.TrimSpace(s.BotToken) != ""
} Try / catch
res, err := runWeixinQRLoginFlow(ctx, opts)
if err != nil && strings.Contains(err.Error(), "bot_token missing") {
// incomplete server payload; retry setup or bind with a manual token
return fmt.Errorf("no token returned; rerun setup or use bind --token")
} Prevention
- Never persist credentials from a confirmed status without a non-empty bot_token
- Track ilink API changes to the token field name
- Verify account-level token issuance is enabled before setup
- Keep bind --token as an escape hatch documented for users
When it happens
Trigger: `cc-connect weixin setup` QR flow: poll status becomes "confirmed", IlinkBotID is present, but strings.TrimSpace(status.BotToken) == "" in the status payload.
Common situations: ilink server bug or partial rollout withholding the token; API field renamed (e.g. bot_token → token) after a server upgrade; token issuance disabled or failing server-side for the account; stub API used for testing.
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
- bind mode requires --token
- login confirmed but ilink_bot_id missing
- invalid json response: %w
- new/QR mode does not accept --token; use `cc-connect weixin
- internal: unknown mode %q
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/706ad698d47ec7df.
Report an issue: GitHub.