Skip to content

fix(wecom): support aibot image pic_url and multiple AES key formats - #17375

Closed
sunday866 wants to merge 1 commit into
NousResearch:mainfrom
sunday866:fix/wecom-aibot-image-decryption
Closed

sunday866 wants to merge 1 commit into
NousResearch:mainfrom
sunday866:fix/wecom-aibot-image-decryption

Conversation

@sunday866

Copy link
Copy Markdown

Summary

Problem

WeCom AI Bot (智能机器人) image messages fail to decrypt with two issues:

  1. AES key format mismatch: The arrives as either a 64-character hex string (via websocket) or a 43-character base64 string without standard padding. The existing code only tried , which throws for both formats.

  2. Missing pic_url support: WeCom AI Bot sends image URLs in the field (not the standard field), so image attachments were never recognized.

Changes

  1. **** (new static method):

    • Tries for 64-char hex strings
    • Adds padding for 43-char base64 strings
    • Falls back to standard
  2. ****:

    • Recognizes field and constructs media reference with corresponding
  3. ****:

    • Uses instead of direct

Testing

  • Tested with WeCom AI Bot image messages on macOS
  • Images now successfully decrypt and display

Related PRs

This PR combines fixes from both approaches into a single comprehensive solution.

WeCom AI Bot delivers image URLs in the pic_url field (not url) and
aeskey as either a 64-char hex string or 43-char base64 without padding.
The existing _decrypt_file_bytes() only tried base64.b64decode() which
threw Incorrect padding for both formats.

Changes:
- Add _decode_wecom_aes_key() to handle 64-char hex, 43-char unpadded
  base64, and standard base64 formats
- Recognize pic_url field in _extract_media() for WeCom AI Bot images
- Use _decode_wecom_aes_key() in _decrypt_file_bytes()

Fixes NousResearch#11447
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter comp/gateway Gateway runner, session dispatch, delivery labels Apr 29, 2026
@alt-glitch

Copy link
Copy Markdown

Combines fixes from #11750 (hex key support) and #12390 (pic_url + unpadded base64). Supersedes both. Fixes #11447.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(wecom): aibot image decryption fails + group @mention not stripped

2 participants