chenhg5/cc-connect · error
wecom-ws: empty aeskey
Error message
wecom-ws: empty aeskey
What it means
Guard at the top of decodeWeComAESKey: the aeskey string accompanying an inbound WeCom media message (image/file) is empty, so there is no key to decrypt the downloaded ciphertext. The key normally arrives on every media callback body, so an empty value means a malformed or unexpected callback payload.
Source
Thrown at platform/wecom/websocket_media.go:207
if body.MsgType == "file" && body.File != nil {
appendFile(¤t, body.File.URL, body.File.Aeskey, false)
}
if body.MsgType == "image" && body.Image != nil {
appendImage(¤t, body.Image.URL, body.Image.Aeskey, false)
}
}
walkQuote(body.Quote)
return current, quoted
}
// decodeWeComAESKey normalizes and decodes the aeskey from WeCom WS callbacks.
// The server may send standard Base64, URL-safe Base64 (- _), omit padding, insert
// whitespace, or (rarely) a 64-char hex string. Node's Buffer.from(s, 'base64') is more
// permissive than Go's StdEncoding; we mirror common cases so decryption matches the SDK.
func decodeWeComAESKey(aesKey string) ([]byte, error) {
s := strings.TrimSpace(aesKey)
if s == "" {
return nil, fmt.Errorf("wecom-ws: empty aeskey")
}
var b strings.Builder
b.Grow(len(s))
for i := 0; i < len(s); i++ {
switch s[i] {
case '\n', '\r', ' ', '\t':
continue
default:
b.WriteByte(s[i])
}
}
s = b.String()
if len(s) == 64 && isHexString(s) {
key, err := hex.DecodeString(s)
if err != nil {
return nil, fmt.Errorf("wecom-ws: decode aeskey hex: %w", err)
}View on GitHub (pinned to 4000b2338a)
Solutions
- Skip the media item and notify/log rather than retrying — the callback payload itself is incomplete
- Verify the callback schema version expected from the WeCom AI-Bot WS feed
- Guard upstream in the media walker so attachments without aeskey are ignored individually without failing the whole message
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at platform/wecom/websocket_media.go:207 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/1a0f95c7645920e7.
Report an issue: GitHub.