{"record":{"id":"961aa0de7cd70fee","repo":"chenhg5/cc-connect","slug":"wecom-ws-bot-id-and-bot-secret-are-required-for-w","errorCode":null,"errorMessage":"wecom-ws: bot_id and bot_secret are required for websocket mode","messagePattern":"wecom-ws: bot_id and bot_secret are required for websocket mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"platform/wecom/websocket.go","lineNumber":124,"sourceCode":"\tQuote      *wsQuoteBlock `json:\"quote,omitempty\"`\n\tCreateTime int64         `json:\"create_time\"`\n}\n\nfunc wsVoiceText(v struct {\n\tText    string `json:\"text,omitempty\"`\n\tContent string `json:\"content,omitempty\"`\n}) string {\n\tif s := strings.TrimSpace(v.Content); s != \"\" {\n\t\treturn s\n\t}\n\treturn strings.TrimSpace(v.Text)\n}\n\nfunc newWebSocket(opts map[string]any) (core.Platform, error) {\n\tbotID, _ := opts[\"bot_id\"].(string)\n\tsecret, _ := opts[\"bot_secret\"].(string)\n\tif botID == \"\" || secret == \"\" {\n\t\treturn nil, fmt.Errorf(\"wecom-ws: bot_id and bot_secret are required for websocket mode\")\n\t}\n\tallowFrom, _ := opts[\"allow_from\"].(string)\n\n\treturn &WSPlatform{\n\t\tbotID:     botID,\n\t\tsecret:    secret,\n\t\tallowFrom: allowFrom,\n\t}, nil\n}\n\n// generateReqID creates a unique req_id with the given prefix (e.g. \"ping_1\", \"aibot_subscribe_2\").\nfunc (p *WSPlatform) generateReqID(prefix string) string {\n\tseq := p.reqSeq.Add(1)\n\treturn fmt.Sprintf(\"%s_%d\", prefix, seq)\n}\n\nfunc (p *WSPlatform) Name() string { return \"wecom\" }\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/websocket.go#L106-L142","documentation":"newWebSocket is the factory for the WeCom WebSocket transport and requires bot_id and bot_secret in the options map. If either is empty, it refuses to construct the platform. This fails fast at startup rather than letting the connection attempt later with invalid credentials.","triggerScenarios":"The [[platform]] config block for wecom websocket mode omits bot_id or bot_secret, or defines them with empty string values, or misspells the keys (e.g. botId).","commonSituations":"Deploying with a template config.toml where placeholders were never filled; switching from webhook mode to websocket mode without adding the ws credentials; environment-variable interpolation producing an empty value.","solutions":["Add bot_id and bot_secret to the wecom platform options in config.toml.","Check key spelling: they must be exactly bot_id and bot_secret.","Verify no empty-string values (e.g. from unset env vars) — print or validate the resolved config.","Confirm you are in websocket mode (which requires these credentials) vs webhook mode (which may not)."],"exampleFix":"// before\n[[platform]]\nname = \"wecom-ws\"\n# bot_id and bot_secret missing\n\n// after\n[[platform]]\nname = \"wecom-ws\"\n[platform.options]\nbot_id = \"ww1234567890\"\nbot_secret = \"your-secret\"","handlingStrategy":"validation","validationCode":"cfg := readPlatformConfig(\"wecom-ws\")\nif cfg[\"bot_id\"] == \"\" || cfg[\"bot_secret\"] == \"\" {\n\treturn errors.New(\"wecom-ws: bot_id and bot_secret must be set in config\")\n}","typeGuard":"null","tryCatchPattern":"p, err := newWebSocket(opts)\nif err != nil {\n\tslog.Fatal(\"wecom-ws platform init failed\", \"err\", err)\n}","preventionTips":["Validate config.toml at startup before spawning platforms","Fill all template placeholders during deployment","Avoid env-var interpolation that silently yields empty strings","Keep webhook and websocket credential requirements documented"],"tags":["wecom","config","validation","startup"],"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-14T00:17:10.932Z"}