{"record":{"id":"b8e33cd4da9090ef","repo":"chenhg5/cc-connect","slug":"cloud-web-token-is-required","errorCode":null,"errorMessage":"cloud_web: token is required","messagePattern":"cloud_web: token is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/cloud-web/cloudweb.go","lineNumber":70,"sourceCode":"\t_ core.CardSender                = (*Platform)(nil)\n\t_ core.CardNavigable             = (*Platform)(nil)\n\t_ core.CardRefresher             = (*Platform)(nil)\n\t_ core.TypingIndicator           = (*Platform)(nil)\n\t_ core.MessageUpdater            = (*Platform)(nil)\n\t_ core.PreviewStarter            = (*Platform)(nil)\n\t_ core.PreviewCleaner            = (*Platform)(nil)\n\t_ core.AsyncRecoverablePlatform  = (*Platform)(nil)\n)\n\nfunc New(opts map[string]any) (core.Platform, error) {\n\tname, _ := opts[\"name\"].(string)\n\tif name == \"\" {\n\t\tname = \"cloud_web\"\n\t}\n\tproject, _ := opts[\"cc_project\"].(string)\n\ttoken, _ := opts[\"token\"].(string)\n\tif strings.TrimSpace(token) == \"\" {\n\t\treturn nil, fmt.Errorf(\"cloud_web: token is required\")\n\t}\n\n\ttransportKind, _ := opts[\"transport\"].(string)\n\tif transportKind == \"\" {\n\t\ttransportKind = \"websocket\"\n\t}\n\tswitch transportKind {\n\tcase \"websocket\", \"long_poll\", \"gateway\":\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"cloud_web: transport must be websocket, long_poll, or gateway\")\n\t}\n\n\tbaseURL, _ := opts[\"base_url\"].(string)\n\twsURL, _ := opts[\"ws_url\"].(string)\n\tlisten, _ := opts[\"listen\"].(string)\n\twebhookPath, _ := opts[\"webhook_path\"].(string)\n\tregisterURL, _ := opts[\"register_url\"].(string)\n\tpublicURL, _ := opts[\"public_url\"].(string)","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/cloud-web/cloudweb.go#L52-L88","documentation":"The cloud_web platform constructor (New) validates options before building the platform. It throws this error when the `token` option is absent, not a string, or consists only of whitespace, because the cloud-web transport cannot authenticate without a token.","triggerScenarios":"Calling cloudweb.New (directly or via core.CreatePlatform(\"cloud_web\", opts) from config) where opts has no \"token\" key, opts[\"token\"] is a non-string (e.g. number), or it is empty/whitespace after strings.TrimSpace.","commonSituations":"Missing token in config.toml [[platform]] options; token defined under the wrong platform block; token passed as a number; empty string from an unexpanded env placeholder; copy-pasting a config example without filling in the token.","solutions":["Set `token = \"<your cloud-web token>\"` in the cloud_web platform's options in config.toml.","Verify the key is exactly `token` inside the cloud_web platform block (not another platform).","Confirm the value is a non-empty quoted string, not a number or unexpanded variable.","If sourcing from an env var, check it is actually set in the daemon's environment (systemd/launchd may have a minimal env)."],"exampleFix":"// before\nopts := map[string]any{\"name\": \"my_web\"}\np, err := cloudweb.New(opts) // error: cloud_web: token is required\n// after\nopts := map[string]any{\"name\": \"my_web\", \"token\": os.Getenv(\"CLOUD_WEB_TOKEN\")}\np, err := cloudweb.New(opts)","handlingStrategy":"validation","validationCode":"func validCloudWebOpts(opts map[string]any) error {\n\ttok, ok := opts[\"token\"].(string)\n\tif !ok || strings.TrimSpace(tok) == \"\" {\n\t\treturn fmt.Errorf(\"cloud_web: token must be a non-empty string before New\")\n\t}\n\treturn nil\n}","typeGuard":"func hasToken(opts map[string]any) bool {\n\ttok, ok := opts[\"token\"].(string)\n\treturn ok && strings.TrimSpace(tok) != \"\"\n}","tryCatchPattern":"p, err := cloudweb.New(opts)\nif err != nil {\n\tif strings.Contains(err.Error(), \"token is required\") {\n\t\tslog.Error(\"cloud_web platform skipped: set the `token` option in config.toml\")\n\t\treturn\n\t}\n\treturn err\n}","preventionTips":["Keep the token in config.toml (or inject via env expansion) inside the cloud_web platform block.","Quote the token as a string; never pass numbers or leave it empty.","Validate config at startup with a lint/check command before running the daemon.","Confirm env vars are set in the daemon's service environment, not just your shell."],"tags":["config","authentication","cloud-web","platform"],"backgroundTag":"missing-required-config-field","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"}