chenhg5/cc-connect · error
bind mode requires --token
Error message
bind mode requires --token
What it means
resolveWeixinSetupMode validates that the requested `bind` setup mode carries a pairing token; bind reuses an existing WeChat account and cannot proceed without its token. The setup flow aborts with this error instead of entering QR pairing.
Source
Thrown at cmd/cc-connect/weixin.go:221
fmt.Printf("✅ Weixin (ilink) configured for project %q\n", saveResult.ProjectName)
fmt.Printf(" Platform: weixin (projects[%d].platforms[%d])\n", saveResult.ProjectIndex, saveResult.PlatformAbsIndex)
if saveResult.AllowFrom != "" {
fmt.Printf(" allow_from: %s\n", saveResult.AllowFrom)
}
fmt.Println()
fmt.Println("Next: run cc-connect (or restart the daemon) and send a message from WeChat to finish linking context_token.")
}
func resolveWeixinSetupMode(requested, token string) (string, error) {
switch requested {
case weixinSetupModeAuto:
if token != "" {
return weixinSetupModeBind, nil
}
return weixinSetupModeNew, nil
case weixinSetupModeBind:
if token == "" {
return "", errors.New("bind mode requires --token")
}
return weixinSetupModeBind, nil
case weixinSetupModeNew:
if token != "" {
return "", errors.New("new/QR mode does not accept --token; use `cc-connect weixin bind --token ...`")
}
return weixinSetupModeNew, nil
default:
return "", fmt.Errorf("internal: unknown mode %q", requested)
}
}
type weixinQRLoginOptions struct {
APIBaseURL string
RouteTag string
BotType string
Timeout time.Duration
QRImage stringView on GitHub (pinned to 4000b2338a)
Solutions
- Re-run setup in bind mode with the saved token: `cc-connect weixin setup --mode bind --token <token>`
- If you have no token, use new/QR mode instead (omit --mode bind and --token)
- Locate the token from the earlier bind output or config before retrying
Example fix
// before cc-connect weixin setup --mode bind // after cc-connect weixin setup --mode bind --token wx_abc123
Defensive patterns
Strategy: validation
Validate before calling
if mode == "bind" && token == "" {
return errors.New("bind requires --token")
} Prevention
- Store the pairing token securely right after the first successful bind
- Choose new/QR mode when no token exists instead of forcing bind
- Verify the token env var is exported before running setup
When it happens
Trigger: Running `cc-connect weixin setup --mode bind` (or equivalent selection) without passing `--token <token>`.
Common situations: Intending to link an existing account but forgetting the token saved from a previous setup, confusing the bind flow with the new/QR flow, or the token env var was empty.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- new/QR mode does not accept --token; use `cc-connect weixin
- 等待扫码超时,请重试
- bind mode requires --token (format: app_key:app_secret)
- --token is required (format: app_key:app_secret)
- no project found in config
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/b676c569fc844f76.
Report an issue: GitHub.