{"record":{"id":"7a954213fe8106eb","repo":"chenhg5/cc-connect","slug":"wecom-corp-id-corp-secret-and-agent-id-are-requ","errorCode":null,"errorMessage":"wecom: corp_id, corp_secret, and agent_id are required","messagePattern":"wecom: corp_id, corp_secret, and agent_id are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"platform/wecom/wecom.go","lineNumber":131,"sourceCode":"\t}\n\td.seen[msgID] = now\n\treturn false\n}\n\nfunc New(opts map[string]any) (core.Platform, error) {\n\tmode, _ := opts[\"mode\"].(string)\n\tif mode == \"websocket\" {\n\t\treturn newWebSocket(opts)\n\t}\n\n\tcorpID, _ := opts[\"corp_id\"].(string)\n\tcorpSecret, _ := opts[\"corp_secret\"].(string)\n\tagentID, _ := opts[\"agent_id\"].(string)\n\tcallbackToken, _ := opts[\"callback_token\"].(string)\n\tcallbackAESKey, _ := opts[\"callback_aes_key\"].(string)\n\n\tif corpID == \"\" || corpSecret == \"\" || agentID == \"\" {\n\t\treturn nil, fmt.Errorf(\"wecom: corp_id, corp_secret, and agent_id are required\")\n\t}\n\tif callbackToken == \"\" || callbackAESKey == \"\" {\n\t\treturn nil, fmt.Errorf(\"wecom: callback_token and callback_aes_key are required\")\n\t}\n\n\taesKey, err := decodeAESKey(callbackAESKey)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"wecom: invalid callback_aes_key: %w\", err)\n\t}\n\n\tport, _ := opts[\"port\"].(string)\n\tif port == \"\" {\n\t\tport = \"8081\"\n\t}\n\tpath, _ := opts[\"callback_path\"].(string)\n\tif path == \"\" {\n\t\tpath = \"/wecom/callback\"\n\t}","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L113-L149","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nopts := map[string]any{\n\t\"corp_id\":     \"\",\n\t\"corp_secret\": os.Getenv(\"WECOM_SECRET\"),\n\t// agent_id missing\n}\np, err := wecom.New(opts)\n// after\nopts := map[string]any{\n\t\"corp_id\":            \"ww1234567890\",\n\t\"corp_secret\":        os.Getenv(\"WECOM_SECRET\"),\n\t\"agent_id\":           \"1000002\",\n\t\"callback_token\":     os.Getenv(\"WECOM_CALLBACK_TOKEN\"),\n\t\"callback_aes_key\":   os.Getenv(\"WECOM_CALLBACK_AES_KEY\"),\n}\np, err := wecom.New(opts)","handlingStrategy":"validation","validationCode":"for _, k := range []string{\"corp_id\", \"corp_secret\", \"agent_id\", \"callback_token\", \"callback_aes_key\"} {\n\tv, _ := opts[k].(string)\n\tif v == \"\" {\n\t\treturn fmt.Errorf(\"wecom: missing option %q\", k)\n\t}\n}","typeGuard":"func optString(opts map[string]any, key string) (string, bool) {\n\ts, ok := opts[key].(string)\n\treturn s, ok && s != \"\"\n}","tryCatchPattern":"p, err := wecom.New(opts)\nif err != nil && strings.Contains(err.Error(), \"are required\") {\n\tlog.Fatal(\"wecom platform misconfigured: set corp_id, corp_secret, agent_id in config.toml\")\n}","preventionTips":["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"],"tags":["configuration","credentials","wecom","initialization"],"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"}