{"record":{"id":"352159a3e6034753","repo":"chenhg5/cc-connect","slug":"token-is-required-format-app-key-app-secret","errorCode":null,"errorMessage":"--token is required (format: app_key:app_secret)","messagePattern":"--token is required \\(format: app_key:app_secret\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/yuanbao.go","lineNumber":132,"sourceCode":"\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\nfunc printYuanbaoUsage() {\n\tfmt.Println(`Usage: cc-connect yuanbao <command> [options]","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/yuanbao.go#L114-L150","documentation":"The non-bind counterpart of [488]: resolveYuanbaoBotToken requires --token in `app_key:app_secret` format, and if the value is absent or malformed (empty, ':' at position 0, trailing ':', or no ':') outside bind mode it returns this error. Both key and secret must be non-empty for the format check to pass.","triggerScenarios":"Running yuanbao setup (create or any non-bind mode) without --token, or with a token that has no ':', an empty key, or an empty secret segment.","commonSituations":"Missing --token flag on the command line; token pasted incompletely; shell ate the ':' portion due to quoting; user confused the token format with a plain API key.","solutions":["Supply --token as \"app_key:app_secret\" with both parts non-empty and the argument quoted","Re-copy the token from the Yuanbao console and verify it contains a colon","Check shell quoting/history so the full token reaches the CLI","Consult `cc-connect setup --help` for the exact expected token format"],"exampleFix":"// before\ncc-connect setup yuanbao --token    # omitted or \"mykey\"\n// after\ncc-connect setup yuanbao --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}\nif !validYuanbaoToken(os.Args[tokenFlagIdx+1]) { /* reject before setup runs */ }","typeGuard":null,"tryCatchPattern":"if err := runYuanbaoSetup(...); err != nil {\n    if strings.Contains(err.Error(), \"--token is required\") {\n        fmt.Fprintln(os.Stderr, `usage: cc-connect setup yuanbao --token \"app_key:app_secret\"`)\n        os.Exit(2)\n    }\n    return err\n}","preventionTips":["Include the full app_key:app_secret with a non-empty secret","Quote the token argument in shell commands and scripts","Verify the pasted token contains a colon before running setup","Keep tokens in an env var or config rather than retyping them"],"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-14T05:17:10.506Z"}