Conversation
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
This was referenced May 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
WeCom AI Bot (智能机器人) image messages fail to decrypt with two issues:
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.
Missing pic_url support: WeCom AI Bot sends image URLs in the field (not the standard field), so image attachments were never recognized.
Changes
**** (new static method):
****:
****:
Testing
Related PRs
This PR combines fixes from both approaches into a single comprehensive solution.