{"record":{"id":"eead61f3980255d2","repo":"chenhg5/cc-connect","slug":"bind-mode-requires-token-format-app-key-app-se","errorCode":null,"errorMessage":"bind mode requires --token (format: app_key:app_secret)","messagePattern":"bind mode requires --token \\(format: app_key:app_secret\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/yuanbao.go","lineNumber":130,"sourceCode":"\t\tos.Exit(1)\n\t}\n\n\tfmt.Printf(\"✅ Yuanbao bot configured for project %q\\n\", saveResult.ProjectName)\n\tfmt.Printf(\"   Platform: yuanbao (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 the platform will\")\n\tfmt.Println(\"auto-fetch sign-tokens via bot_token and connect over WebSocket.\")\n}\n\nfunc resolveYuanbaoBotToken(mode, raw string) (string, error) {\n\ttoken := strings.TrimSpace(raw)\n\tidx := strings.Index(token, \":\")\n\tif token == \"\" || idx <= 0 || idx >= len(token)-1 {\n\t\tif mode == yuanbaoSetupModeBind {\n\t\t\treturn \"\", fmt.Errorf(\"bind mode requires --token (format: app_key:app_secret)\")\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"--token is required (format: app_key:app_secret)\")\n\t}\n\treturn token, nil\n}\n\n// splitYuanbaoTokenForVerify is the same split as platform/yuanbao's\n// splitBotToken, inlined here so the CLI doesn't need to import internal\n// helpers of the platform package.\nfunc splitYuanbaoTokenForVerify(raw string) (appKey, appSecret string) {\n\traw = strings.TrimSpace(raw)\n\tidx := strings.Index(raw, \":\")\n\tif idx <= 0 || idx >= len(raw)-1 {\n\t\treturn \"\", \"\"\n\t}\n\treturn strings.TrimSpace(raw[:idx]), strings.TrimSpace(raw[idx+1:])\n}\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/yuanbao.go#L112-L148","documentation":"resolveYuanbaoBotToken parses the --token flag, which must be in `app_key:app_secret` form. In bind setup mode, an empty token or one without a non-empty key and secret separated by ':' is rejected with this error. Bind mode always requires an existing bot token because it attaches to an already-created Yuanbao bot rather than creating one.","triggerScenarios":"Running yuanbao setup with mode=bind while --token is missing, empty, whitespace-only, starts with ':', ends with ':', or contains no ':' at all (strings.Index returns -1, failing the idx > 0 and idx < len-1 checks).","commonSituations":"User forgot the --token flag entirely; pasted only the app_key without the :app_secret part; shell quoting split the token so only part of it arrived; used create mode's looser expectations while running bind.","solutions":["Pass --token in exactly `app_key:app_secret` form, quoted: --token \"mykey:mysecret\"","Copy the full token from the Yuanbao bot console including the colon separator","Quote the argument so shells do not split or glob it","If you have no existing bot token, run setup in create mode instead of bind mode"],"exampleFix":"// before\ncc-connect setup yuanbao --mode bind --token mykey   # missing :secret\n// after\ncc-connect setup yuanbao --mode bind --token \"mykey:mysecret\"","handlingStrategy":"validation","validationCode":"func validYuanbaoToken(s string) bool {\n    k, sec, ok := strings.Cut(strings.TrimSpace(s), \":\")\n    return ok && k != \"\" && sec != \"\"\n}\n// check before invoking setup bind mode\nif mode == \"bind\" && !validYuanbaoToken(tokenFlag) { /* error out early */ }","typeGuard":null,"tryCatchPattern":"if err := runYuanbaoSetup(...); err != nil {\n    if strings.Contains(err.Error(), \"bind mode requires --token\") {\n        fmt.Fprintln(os.Stderr, `usage: cc-connect setup yuanbao --mode bind --token \"app_key:app_secret\"`)\n        os.Exit(2)\n    }\n    return err\n}","preventionTips":["Always quote --token so shells preserve the colon-separated parts","Copy the full app_key:app_secret pair from the console","Choose bind mode only when you already hold a bot token","Add a shell alias/script that embeds the correctly quoted token"],"tags":["cli","validation","token","yuanbao","setup"],"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"}