{"record":{"id":"bc15ee1e54fcfe70","repo":"chenhg5/cc-connect","slug":"wecom-invalid-callback-aes-key-w","errorCode":null,"errorMessage":"wecom: invalid callback_aes_key: %w","messagePattern":"wecom: invalid callback_aes_key: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/wecom.go","lineNumber":139,"sourceCode":"\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}\n\tapiBaseURL, _ := opts[\"api_base_url\"].(string)\n\tapiBaseURL = strings.TrimRight(strings.TrimSpace(apiBaseURL), \"/\")\n\tif apiBaseURL == \"\" {\n\t\tapiBaseURL = defaultAPIBaseURL\n\t} else {\n\t\tparsed, err := url.Parse(apiBaseURL)\n\t\tif err != nil || (parsed.Scheme != \"https\" && parsed.Scheme != \"http\") || parsed.Host == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"wecom: invalid api_base_url %q: must be a valid http(s) URL\", apiBaseURL)","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L121-L157","documentation":"The callback_aes_key option must be the EncodingAESKey string from WeCom, which is 43 Base64-ish characters and decodes to a 32-byte AES key. New() validates this by calling decodeAESKey; if decoding fails (wrong length, non-standard characters), construction fails with this wrapped error.","triggerScenarios":"Passing a callback_aes_key whose decoded length is not 32 bytes (decodeAESKey failure), e.g. a truncated copy-paste, a plaintext secret that is not the EncodingAESKey, extra whitespace/quotes, or using the corp_secret or Token field by mistake.","commonSituations":"Copy-pasting the EncodingAESKey from the WeCom console with surrounding quotes or whitespace; confusing the random Token with the EncodingAESKey; hand-generating an arbitrary key that isn't exactly 43 chars in the expected alphabet; an old key from a deleted app.","solutions":["Copy the EncodingAESKey verbatim (43 characters) from the WeCom admin console 'Receive Messages' settings and re-enter it","Strip surrounding quotes, spaces, or newlines from the value in your config","Ensure you are using the EncodingAESKey, not the callback Token or corp_secret","Check decodeAESKey's expected format in platform/wecom and validate your key locally before startup"],"exampleFix":"// before\n\"callback_aes_key\": \"shortkey\" // wrong length -> invalid callback_aes_key\n// after\n\"callback_aes_key\": \"yLI7dD1234567890abcdefghijklmnopqrstuvwxyzABC\" // 43-char EncodingAESKey","handlingStrategy":"validation","validationCode":"key, _ := opts[\"callback_aes_key\"].(string)\nif len(key) != 43 {\n\treturn fmt.Errorf(\"EncodingAESKey must be exactly 43 characters, got %d\", len(key))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always copy the EncodingAESKey verbatim from the WeCom console — never retype it","Trim whitespace/newlines from pasted config values","Never confuse Token, EncodingAESKey, and corp_secret; label them in your secret store","Test decryption locally (decodeAESKey) before deploying"],"tags":["wecom","config","crypto","validation"],"backgroundTag":"invalid-config-value","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"}