fix(wecom): pad base64 aeskey before decoding in media decrypt - #14888
Closed
cocoyingrui wants to merge 1 commit into
Closed
fix(wecom): pad base64 aeskey before decoding in media decrypt#14888cocoyingrui wants to merge 1 commit into
cocoyingrui wants to merge 1 commit into
Conversation
WeCom AI Bot returns aeskey values without trailing = padding in the base64 string. base64.b64decode() raises Incorrect padding when the key length is not a multiple of 4. Add standard base64 padding before decoding to handle keys of any length. This fixes inbound image/file messages failing silently with Failed to decrypt errors.
Collaborator
This was referenced Apr 27, 2026
This was referenced May 5, 2026
Contributor
|
Thanks for the focused WeCom media-decryption fix. This is already implemented on current
|
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.
Problem
WeCom AI Bot WebSocket (
aibot_msg_callback) delivers inbound image/file messages with anaeskeyfield that is base64-encoded but omits trailing=padding — for example:base64.b64decode()raisesIncorrect paddingwhen the input length is not a multiple of 4, causing_decrypt_file_bytesto fail silently. The image/file downloads successfully but is never cached, so_extract_mediareturns an empty list and the message is dropped as "Empty WeCom message skipped".Root Cause
_decrypt_file_bytesingateway/platforms/wecom.pycallsbase64.b64decode(aes_key)without padding normalization.Fix
Add standard base64 padding before decoding:
Testing
Tested with WeCom AI Bot in production:
OpenClaw's wecom-openclaw-plugin handles the same aeskey format via
wsClient.downloadFile(url, aeskey)which pads internally — confirming this is the expected format from WeCom's API.Affected Versions
v0.10.0, v0.11.0 (and likely all versions since WeCom media decrypt was added)