hermes - ✅(Solved) Fix Weixin image sends can fail on large uploads with CDN 500 / broken pipe [1 pull requests, 1 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#14456Fetched 2026-04-24 06:17:07
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3cross-referenced ×1

Root Cause

The Weixin upload path is brittle for larger images and had no automatic compression/retry fallback.

Fix Action

Fixed

PR fix notes

PR #14458: fix(weixin): auto-compress large image retries

Description (problem / solution / changelog)

Summary

  • add a Weixin image-upload fallback for large images that fail with CDN upload 500 / broken pipe
  • retry failed image sends with ffmpeg-based downscaling + JPEG compression
  • route Weixin image send paths consistently through send_image_file()
  • add regression coverage for retry, timeout, square-image scaling, direct-send routing, fresh-session retry, and BMP handling

Root cause

Large images could fail on the Weixin CDN upload step even when the source file itself was valid. The existing send path retried nothing and treated all image uploads the same, so affected images were never delivered.

What changed

  • detect retryable upload failures
  • compress oversized images with ffmpeg before retrying
  • retry the compressed upload with a fresh session
  • unify image extension handling for direct-send paths
  • make send_image() go through the image-specific send path

Tests

  • python -m pytest tests/gateway/test_weixin.py -q

Verification

  • reproduced the failure against the real Weixin path
  • confirmed the original image upload fails first
  • confirmed the compressed fallback succeeds and the image can be delivered

Linked issue

Fixes #14456

Changed files

  • gateway/platforms/weixin.py (modified, +126/-9)
  • tests/gateway/test_weixin.py (modified, +146/-0)
RAW_BUFFERClick to expand / collapse

Bug Description

Weixin image delivery can fail for valid local image files, especially larger images, during CDN upload.

Symptoms

  • image file exists and is valid
  • send attempt fails with:
    • CDN upload HTTP 500
    • sometimes [Errno 32] Broken pipe

Steps to Reproduce

  1. Send a larger image through the Weixin media path
  2. Observe upload failure from the CDN step

Expected Behavior

The image should still be delivered, or the adapter should retry with a compatible fallback.

Actual Behavior

The upload fails and the image is not delivered.

Root Cause

The Weixin upload path is brittle for larger images and had no automatic compression/retry fallback.

Proposed Fix

  • detect retryable upload failures
  • compress/downscale large images with ffmpeg
  • retry with a fresh session
  • route all Weixin image send paths consistently through the image-specific path

extent analysis

TL;DR

Implementing image compression and retry mechanisms for Weixin image uploads can resolve the delivery failures for larger images.

Guidance

  • Verify that the issue is indeed related to large image sizes by testing with smaller images to see if the upload succeeds.
  • Consider implementing a fallback mechanism to compress or downscale large images using a tool like ffmpeg before retrying the upload.
  • Review the Weixin API documentation to ensure that the upload process is correctly handling errors and retries, and adjust the implementation accordingly.
  • Test the proposed fix by sending larger images through the modified Weixin media path and observing if the upload is successful.

Example

import ffmpeg

# Example of compressing an image using ffmpeg
def compress_image(image_path):
    stream = ffmpeg.input(image_path)
    stream = ffmpeg.output(stream, 'output.jpg', **{'vcodec': 'libx264', 'crf': 18})
    ffmpeg.run(stream)

Notes

The proposed fix assumes that the Weixin API supports retrying uploads and that the issue is solely related to large image sizes. Additional error handling and logging may be necessary to ensure the fix is robust.

Recommendation

Apply workaround: Implementing image compression and retry mechanisms for Weixin image uploads, as the root cause is identified as the brittleness of the upload path for larger images.

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