chenhg5/cc-connect · critical
wecom: corp_id, corp_secret, and agent_id are required
Error message
wecom: corp_id, corp_secret, and agent_id are required
What it means
The wecom platform constructor New() validates that the required WeCom credentials are present in the options map: corp_id, corp_secret, and agent_id. Any of them missing or empty (or not a string) aborts platform creation because the platform cannot authenticate to the WeCom API without them.
Source
Thrown at platform/wecom/wecom.go:131
}
d.seen[msgID] = now
return false
}
func New(opts map[string]any) (core.Platform, error) {
mode, _ := opts["mode"].(string)
if mode == "websocket" {
return newWebSocket(opts)
}
corpID, _ := opts["corp_id"].(string)
corpSecret, _ := opts["corp_secret"].(string)
agentID, _ := opts["agent_id"].(string)
callbackToken, _ := opts["callback_token"].(string)
callbackAESKey, _ := opts["callback_aes_key"].(string)
if corpID == "" || corpSecret == "" || agentID == "" {
return nil, fmt.Errorf("wecom: corp_id, corp_secret, and agent_id are required")
}
if callbackToken == "" || callbackAESKey == "" {
return nil, fmt.Errorf("wecom: callback_token and callback_aes_key are required")
}
aesKey, err := decodeAESKey(callbackAESKey)
if err != nil {
return nil, fmt.Errorf("wecom: invalid callback_aes_key: %w", err)
}
port, _ := opts["port"].(string)
if port == "" {
port = "8081"
}
path, _ := opts["callback_path"].(string)
if path == "" {
path = "/wecom/callback"
}View on GitHub (pinned to 4000b2338a)
Solutions
- Add corp_id, corp_secret, and agent_id to the platform options in config.toml with real values from the WeCom admin console
- Check key spelling and that each value is a quoted string (non-string types are silently dropped by the opts assertion)
- Ensure the config file actually loaded — verify cc-connect is reading the TOML you edited
- Cross-check against config.example.toml for the exact key names
Example fix
// before
opts := map[string]any{
"corp_id": "",
"corp_secret": os.Getenv("WECOM_SECRET"),
// agent_id missing
}
p, err := wecom.New(opts)
// after
opts := map[string]any{
"corp_id": "ww1234567890",
"corp_secret": os.Getenv("WECOM_SECRET"),
"agent_id": "1000002",
"callback_token": os.Getenv("WECOM_CALLBACK_TOKEN"),
"callback_aes_key": os.Getenv("WECOM_CALLBACK_AES_KEY"),
}
p, err := wecom.New(opts) Defensive patterns
Strategy: validation
Validate before calling
for _, k := range []string{"corp_id", "corp_secret", "agent_id", "callback_token", "callback_aes_key"} {
v, _ := opts[k].(string)
if v == "" {
return fmt.Errorf("wecom: missing option %q", k)
}
} Type guard
func optString(opts map[string]any, key string) (string, bool) {
s, ok := opts[key].(string)
return s, ok && s != ""
} Try / catch
p, err := wecom.New(opts)
if err != nil && strings.Contains(err.Error(), "are required") {
log.Fatal("wecom platform misconfigured: set corp_id, corp_secret, agent_id in config.toml")
} Prevention
- Validate all wecom config keys at startup with a preflight check
- Source secrets from env vars, never hardcode in TOML
- Diff your [platform.wecom] section against config.example.toml after upgrades
- Remember non-string TOML types (numbers for agent_id) fail the string assertion — quote them
When it happens
Trigger: Calling wecom.New(opts) (or starting cc-connect with a [platform.wecom] config) where opts lacks corp_id, corp_secret, or agent_id, or one is set to "" or a non-string value.
Common situations: Copy-pasting config.example.toml and leaving placeholders empty; missing a key during environment-specific config; typo'd TOML key names so the lookup yields empty; using the callback-only config (callback_token/aes_key present) while forgetting the corp credentials.
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
- qqbot: app_secret is required
- tuitui: app_id and app_secret are required
- app_id/app_secret are required
- wecom-ws: ack timeout
- acp: agent option "cmd" or "command" is required (path or na
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/7a954213fe8106eb.
Report an issue: GitHub.