{"record":{"id":"b676c569fc844f76","repo":"chenhg5/cc-connect","slug":"bind-mode-requires-token","errorCode":null,"errorMessage":"bind mode requires --token","messagePattern":"bind mode requires --token","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/weixin.go","lineNumber":221,"sourceCode":"\tfmt.Printf(\"✅ Weixin (ilink) configured for project %q\\n\", saveResult.ProjectName)\n\tfmt.Printf(\"   Platform: weixin (projects[%d].platforms[%d])\\n\", saveResult.ProjectIndex, saveResult.PlatformAbsIndex)\n\tif saveResult.AllowFrom != \"\" {\n\t\tfmt.Printf(\"   allow_from: %s\\n\", saveResult.AllowFrom)\n\t}\n\tfmt.Println()\n\tfmt.Println(\"Next: run cc-connect (or restart the daemon) and send a message from WeChat to finish linking context_token.\")\n}\n\nfunc resolveWeixinSetupMode(requested, token string) (string, error) {\n\tswitch requested {\n\tcase weixinSetupModeAuto:\n\t\tif token != \"\" {\n\t\t\treturn weixinSetupModeBind, nil\n\t\t}\n\t\treturn weixinSetupModeNew, nil\n\tcase weixinSetupModeBind:\n\t\tif token == \"\" {\n\t\t\treturn \"\", errors.New(\"bind mode requires --token\")\n\t\t}\n\t\treturn weixinSetupModeBind, nil\n\tcase weixinSetupModeNew:\n\t\tif token != \"\" {\n\t\t\treturn \"\", errors.New(\"new/QR mode does not accept --token; use `cc-connect weixin bind --token ...`\")\n\t\t}\n\t\treturn weixinSetupModeNew, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"internal: unknown mode %q\", requested)\n\t}\n}\n\ntype weixinQRLoginOptions struct {\n\tAPIBaseURL string\n\tRouteTag   string\n\tBotType    string\n\tTimeout    time.Duration\n\tQRImage    string","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/weixin.go#L203-L239","documentation":"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.","triggerScenarios":"Running `cc-connect weixin setup --mode bind` (or equivalent selection) without passing `--token <token>`.","commonSituations":"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.","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"],"exampleFix":"// before\ncc-connect weixin setup --mode bind\n// after\ncc-connect weixin setup --mode bind --token wx_abc123","handlingStrategy":"validation","validationCode":"if mode == \"bind\" && token == \"\" {\n    return errors.New(\"bind requires --token\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["weixin","setup","cli","token"],"backgroundTag":"missing-required-flag","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}