chenhg5/cc-connect · error
%s: aes_key hex inside base64: %w
Error message
%s: aes_key hex inside base64: %w
What it means
Inside parseAesKey, the base64-decoded aes_key was 32 bytes of ASCII that matched the hex pattern, but hex.DecodeString still failed — theoretically impossible after regex validation, so this indicates corrupt data or a regex/decoder mismatch on the CDN media key.
Source
Thrown at platform/weixin/cdn.go:104
}
return pkcs7Unpad(out, aes.BlockSize)
}
// parseAesKey decodes CDNMedia.aes_key: base64(raw 16 bytes) or base64(32-char hex ASCII) → 16 bytes.
func parseAesKey(aesKeyBase64, label string) ([]byte, error) {
decoded, err := base64.StdEncoding.DecodeString(strings.TrimSpace(aesKeyBase64))
if err != nil {
return nil, fmt.Errorf("%s: aes_key base64: %w", label, err)
}
if len(decoded) == 16 {
return decoded, nil
}
if len(decoded) == 32 {
s := string(decoded)
if hex32RE.MatchString(s) {
k, err := hex.DecodeString(s)
if err != nil {
return nil, fmt.Errorf("%s: aes_key hex inside base64: %w", label, err)
}
return k, nil
}
}
return nil, fmt.Errorf("%s: aes_key must be 16 raw bytes or 32-char hex (base64-wrapped), got %d bytes after base64", label, len(decoded))
}
func buildCdnDownloadURL(encryptedQueryParam, cdnBase string) string {
return fmt.Sprintf("%s/download?encrypted_query_param=%s",
strings.TrimRight(cdnBase, "/"),
url.QueryEscape(encryptedQueryParam))
}
func buildCdnUploadURL(cdnBase, uploadParam, filekey string) string {
return fmt.Sprintf("%s/upload?encrypted_query_param=%s&filekey=%s",
strings.TrimRight(cdnBase, "/"),
url.QueryEscape(uploadParam),
url.QueryEscape(filekey))View on GitHub (pinned to 4000b2338a)
Solutions
- Log the offending decoded string (it is key material metadata, not a secret payload) to see why hex decoding rejects it
- Tighten or replace hex32RE so it exactly matches hex.DecodeString's accepted alphabet (0-9a-f, case handling)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at platform/weixin/cdn.go:104 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/26b05f15924f9637.
Report an issue: GitHub.