hermes - ✅(Solved) Fix fix(wecom): aibot image decryption fails + group @mention not stripped [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#11447Fetched 2026-04-18 06:01:02
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
commented ×1cross-referenced ×1

Error Message

WeCom aibot (智能机器人) delivers the image aeskey as a 64-char hex string, but _decrypt_file_bytes at gateway/platforms/wecom.py:997 blindly calls base64.b64decode(aes_key), which throws binascii.Error: Incorrect padding. The agent never sees the image attachment.

Root Cause

WeCom group messages arrive with a plain-text @<DisplayName> prefix but no structured mention field (unlike feishu/discord). So /reset, /sethome etc. never match because the text starts with @BotName /reset.

Fix Action

Fixed

PR fix notes

PR #11750: fix(wecom): accept aibot hex keys and strip group mentions

Description (problem / solution / changelog)

Summary

  • accept 64-character hex aeskey values from the WeCom aibot websocket while preserving the existing base64 callback flow
  • strip a configured plain-text @BotName prefix from group messages before slash-command detection
  • expose bot_display_name via config/env wiring and document it in the CLI config example

Root Cause

WeCom aibot image payloads can deliver aeskey as a 64-character hex string, but _decrypt_file_bytes() only tried base64 decoding. Group chat messages also arrive with a literal @DisplayName prefix and no structured mention metadata, so commands like @Hermes /reset never reached the existing slash-command path.

Testing

  • python3 -m py_compile /Users/stephenyu/Documents/hermes-agent-wt-11447/gateway/platforms/wecom.py /Users/stephenyu/Documents/hermes-agent-wt-11447/gateway/config.py /Users/stephenyu/Documents/hermes-agent-wt-11447/tests/gateway/test_wecom.py
  • uv run --directory /Users/stephenyu/Documents/hermes-agent-wt-11447 --extra dev pytest -o addopts='' /Users/stephenyu/Documents/hermes-agent-wt-11447/tests/gateway/test_wecom.py -q

Platform Tested

  • macOS

Contribution Guide Notes

  • updates cli-config.yaml.example for the new platforms.wecom.extra.bot_display_name knob
  • resolves #11447

Changed files

  • cli-config.yaml.example (modified, +3/-0)
  • gateway/config.py (modified, +3/-0)
  • gateway/platforms/wecom.py (modified, +21/-1)
  • tests/gateway/test_wecom.py (modified, +55/-1)

Code Example

[Wecom] Failed to decrypt image from https://ww-aibot-img-...cos.ap-guangzhou.myqcloud.com/...: Incorrect padding
RAW_BUFFERClick to expand / collapse

Bug 1: Image decryption fails with Incorrect padding

WeCom aibot (智能机器人) delivers the image aeskey as a 64-char hex string, but _decrypt_file_bytes at gateway/platforms/wecom.py:997 blindly calls base64.b64decode(aes_key), which throws binascii.Error: Incorrect padding. The agent never sees the image attachment.

[Wecom] Failed to decrypt image from https://ww-aibot-img-...cos.ap-guangzhou.myqcloud.com/...: Incorrect padding

Fix: try bytes.fromhex() first (len==64), fall back to base64 for callback-app keys.

Bug 2: Slash commands don't work in group chats

WeCom group messages arrive with a plain-text @<DisplayName> prefix but no structured mention field (unlike feishu/discord). So /reset, /sethome etc. never match because the text starts with @BotName /reset.

Fix: add optional bot_display_name config / WECOM_BOT_DISPLAY_NAME env, strip the prefix in _extract_text().

Environment

  • hermes v2026.4.8
  • WeCom aibot (智能机器人) via websocket callback
  • macOS

extent analysis

TL;DR

Update the _decrypt_file_bytes function in wecom.py to use bytes.fromhex() for 64-character hex strings and add a configuration option to strip the bot display name prefix from incoming messages.

Guidance

  • For Bug 1, modify the _decrypt_file_bytes function to first attempt decryption using bytes.fromhex() for 64-character hex strings, falling back to base64.b64decode() for other cases.
  • For Bug 2, introduce a bot_display_name configuration option or WECOM_BOT_DISPLAY_NAME environment variable to allow stripping the bot display name prefix from incoming group chat messages.
  • Verify the fixes by testing image decryption and slash commands in both direct and group chats.
  • Consider adding logging to track any decryption or parsing errors for further debugging.

Example

def _decrypt_file_bytes(aes_key):
    if len(aes_key) == 64:  # 64-char hex string
        aes_key_bytes = bytes.fromhex(aes_key)
    else:
        aes_key_bytes = base64.b64decode(aes_key)
    # Proceed with decryption using aes_key_bytes

Notes

The provided fixes assume that the bytes.fromhex() approach works for all 64-character hex strings and that the bot display name prefix is consistently formatted. Additional testing may be necessary to ensure compatibility with all possible input formats.

Recommendation

Apply the workarounds for both Bug 1 and Bug 2, as they address specific, identified issues with minimal risk of introducing new problems.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix fix(wecom): aibot image decryption fails + group @mention not stripped [1 pull requests, 1 comments, 2 participants]