chenhg5/cc-connect · critical
wecom-ws: bot_id and bot_secret are required for websocket m
Error message
wecom-ws: bot_id and bot_secret are required for websocket mode
What it means
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.
Source
Thrown at platform/wecom/websocket.go:124
Quote *wsQuoteBlock `json:"quote,omitempty"`
CreateTime int64 `json:"create_time"`
}
func wsVoiceText(v struct {
Text string `json:"text,omitempty"`
Content string `json:"content,omitempty"`
}) string {
if s := strings.TrimSpace(v.Content); s != "" {
return s
}
return strings.TrimSpace(v.Text)
}
func newWebSocket(opts map[string]any) (core.Platform, error) {
botID, _ := opts["bot_id"].(string)
secret, _ := opts["bot_secret"].(string)
if botID == "" || secret == "" {
return nil, fmt.Errorf("wecom-ws: bot_id and bot_secret are required for websocket mode")
}
allowFrom, _ := opts["allow_from"].(string)
return &WSPlatform{
botID: botID,
secret: secret,
allowFrom: allowFrom,
}, nil
}
// generateReqID creates a unique req_id with the given prefix (e.g. "ping_1", "aibot_subscribe_2").
func (p *WSPlatform) generateReqID(prefix string) string {
seq := p.reqSeq.Add(1)
return fmt.Sprintf("%s_%d", prefix, seq)
}
func (p *WSPlatform) Name() string { return "wecom" }
View on GitHub (pinned to 4000b2338a)
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).
Example fix
// before [[platform]] name = "wecom-ws" # bot_id and bot_secret missing // after [[platform]] name = "wecom-ws" [platform.options] bot_id = "ww1234567890" bot_secret = "your-secret"
Defensive patterns
Strategy: validation
Validate before calling
cfg := readPlatformConfig("wecom-ws")
if cfg["bot_id"] == "" || cfg["bot_secret"] == "" {
return errors.New("wecom-ws: bot_id and bot_secret must be set in config")
} Type guard
null
Try / catch
p, err := newWebSocket(opts)
if err != nil {
slog.Fatal("wecom-ws platform init failed", "err", err)
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- wecom: callback_token and callback_aes_key are required
- wecom: invalid callback_aes_key: %w
- wecom: invalid api_base_url %q: must be a valid http(s) URL
- PreflightRunAsUser: RunAsUser is empty
- tmux: 'session' option is required (name of the tmux session
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/961aa0de7cd70fee.
Report an issue: GitHub.