hermes - 💡(How to fix) Fix [Weixin] send_image_file() fails due to parameter name mismatch [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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#13769Fetched 2026-04-22 08:04:13
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×2

Error Message

Sending local images via MEDIA:/path/to/image.png to Weixin fails silently. The image is not delivered, and the gateway logs report a parameter mismatch error.

Error Log

WARNING gateway.platforms.base: [Weixin] Error sending media: WeixinAdapter.send_image_file() got an unexpected keyword argument 'image_path' 4. Check ~/.hermes/logs/gateway.error.log for the error above.

Root Cause

In gateway/platforms/base.py, send_image_file() is called with the keyword argument image_path=:

# gateway/platforms/base.py ~L1838
media_result = await self.send_image_file(
    chat_id=event.source.chat_id,
    image_path=media_path,   # <-- keyword is 'image_path'
    metadata=_thread_metadata,
)

However, in gateway/platforms/weixin.py, the method signature uses path instead of image_path:

# gateway/platforms/weixin.py ~L1542
async def send_image_file(
    self,
    chat_id: str,
    path: str,               # <-- parameter is named 'path'
    caption: str = "",
    ...
) -> SendResult:
    return await self.send_document(chat_id, file_path=path, ...)

Because the parameter names do not match, Python raises TypeError: WeixinAdapter.send_image_file() got an unexpected keyword argument 'image_path'.

Code Example

WARNING gateway.platforms.base: [Weixin] Error sending media: WeixinAdapter.send_image_file() got an unexpected keyword argument 'image_path'

---

# gateway/platforms/base.py ~L1838
media_result = await self.send_image_file(
    chat_id=event.source.chat_id,
    image_path=media_path,   # <-- keyword is 'image_path'
    metadata=_thread_metadata,
)

---

# gateway/platforms/weixin.py ~L1542
async def send_image_file(
    self,
    chat_id: str,
    path: str,               # <-- parameter is named 'path'
    caption: str = "",
    ...
) -> SendResult:
    return await self.send_document(chat_id, file_path=path, ...)

---

MEDIA:/Users/qiao/Desktop/example.png

---

-    path: str,
+    image_path: str,

---

-    return await self.send_document(chat_id, file_path=path, caption=caption, metadata=metadata)
+    return await self.send_document(chat_id, file_path=image_path, caption=caption, metadata=metadata)
RAW_BUFFERClick to expand / collapse

Bug Description

Sending local images via MEDIA:/path/to/image.png to Weixin fails silently. The image is not delivered, and the gateway logs report a parameter mismatch error.

Error Log

WARNING gateway.platforms.base: [Weixin] Error sending media: WeixinAdapter.send_image_file() got an unexpected keyword argument 'image_path'

Root Cause

In gateway/platforms/base.py, send_image_file() is called with the keyword argument image_path=:

# gateway/platforms/base.py ~L1838
media_result = await self.send_image_file(
    chat_id=event.source.chat_id,
    image_path=media_path,   # <-- keyword is 'image_path'
    metadata=_thread_metadata,
)

However, in gateway/platforms/weixin.py, the method signature uses path instead of image_path:

# gateway/platforms/weixin.py ~L1542
async def send_image_file(
    self,
    chat_id: str,
    path: str,               # <-- parameter is named 'path'
    caption: str = "",
    ...
) -> SendResult:
    return await self.send_document(chat_id, file_path=path, ...)

Because the parameter names do not match, Python raises TypeError: WeixinAdapter.send_image_file() got an unexpected keyword argument 'image_path'.

Reproduction Steps

  1. Start Hermes gateway with Weixin platform enabled.
  2. Send a message that includes a local image reference, e.g.:
    MEDIA:/Users/qiao/Desktop/example.png
  3. Observe that the image is not received on Weixin.
  4. Check ~/.hermes/logs/gateway.error.log for the error above.

Proposed Fix

Rename the parameter in gateway/platforms/weixin.py from path to image_path to align with the base class contract:

-    path: str,
+    image_path: str,

And update the internal reference accordingly:

-    return await self.send_document(chat_id, file_path=path, caption=caption, metadata=metadata)
+    return await self.send_document(chat_id, file_path=image_path, caption=caption, metadata=metadata)

Environment

  • Hermes version: latest main (commit range includes weixin adapter)
  • Platform: macOS (but affects all platforms using Weixin gateway)
  • Python: 3.11

extent analysis

TL;DR

Renaming the path parameter to image_path in gateway/platforms/weixin.py should fix the issue with sending local images via Weixin.

Guidance

  • Verify that the send_image_file method in gateway/platforms/base.py is indeed calling the method with the keyword argument image_path.
  • Check the gateway/platforms/weixin.py file to confirm that the method signature uses the path parameter instead of image_path.
  • Apply the proposed fix by renaming the path parameter to image_path in gateway/platforms/weixin.py and update the internal reference accordingly.
  • After applying the fix, re-run the reproduction steps to verify that the image is sent successfully.

Example

The corrected method signature in gateway/platforms/weixin.py should look like this:

async def send_image_file(
    self,
    chat_id: str,
    image_path: str,               # <-- parameter is now named 'image_path'
    caption: str = "",
    ...
) -> SendResult:
    return await self.send_document(chat_id, file_path=image_path, ...)

Notes

This fix assumes that the issue is solely due to the parameter name mismatch between the base class and the Weixin adapter. If other issues arise after applying this fix, further investigation may be necessary.

Recommendation

Apply the workaround by renaming the path parameter to image_path in gateway/platforms/weixin.py, as this directly addresses the identified root cause of the issue.

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