{"record":{"id":"cc493936d68d5c7e","repo":"sipeed/picoclaw","slug":"decode-aes-key-w","errorCode":null,"errorMessage":"decode AES key: %w","messagePattern":"decode AES key: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/wecom/media.go","lineNumber":96,"sourceCode":"\t\t\tMediaID:     m.MediaID,\n\t\t\tTitle:       m.Title,\n\t\t\tDescription: m.Description,\n\t\t}\n\t}\n\treturn body\n}\n\nfunc decodeMediaAESKey(value string) ([]byte, error) {\n\tif value == \"\" {\n\t\treturn nil, nil\n\t}\n\tkey, err := base64.StdEncoding.DecodeString(value)\n\tif err == nil && len(key) == 32 {\n\t\treturn key, nil\n\t}\n\tkey, err = base64.StdEncoding.DecodeString(value + \"=\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"decode AES key: %w\", err)\n\t}\n\tif len(key) != 32 {\n\t\treturn nil, fmt.Errorf(\"invalid AES key length %d\", len(key))\n\t}\n\treturn key, nil\n}\n\nfunc decryptAESCBC(key, ciphertext []byte) ([]byte, error) {\n\tif len(ciphertext) == 0 {\n\t\treturn nil, fmt.Errorf(\"ciphertext is empty\")\n\t}\n\tif len(ciphertext)%aes.BlockSize != 0 {\n\t\treturn nil, fmt.Errorf(\"ciphertext length %d is not a multiple of block size\", len(ciphertext))\n\t}\n\tblock, err := aes.NewCipher(key)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create cipher: %w\", err)\n\t}","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/wecom/media.go#L78-L114","documentation":"Returned by decodeMediaAESKey: the configured WeCom media AES key is neither valid base64 on its own nor valid after appending one padding '=' character; the base64 decode error is wrapped with %w. The key never reaches length validation — it cannot even be decoded.","triggerScenarios":"Thrown at pkg/channels/wecom/media.go:96 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Copy the exact base64-encoded AES key from the WeCom admin console (typically 43 chars for a 32-byte key)","Check for truncation, embedded whitespace, or URL-safe (-/_) vs standard (+/) base64 alphabet mismatches","Leave the setting empty if no media decryption is configured"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}