Skip to content

Bug: MEDIA directive silently fails on Windows #34632

@GuyueHermit

Description

@GuyueHermit

Environment

  • OS: Windows 10
  • Hermes version: latest
  • Shell: git-bash (MSYS)
  • Platform: Telegram

Bug 1: MEDIA regex only matches Unix paths, not Windows paths

In gateway/platforms/base.py, the MEDIA tag extraction regex uses (?:~/|/) which only matches paths starting with ~/ or /. Windows absolute paths like C:\Users\... are silently ignored.

Steps to reproduce:

  1. On Windows, Hermes produces a response containing MEDIA:C:\Users\kotsu\file.pdf
  2. The MEDIA tag is silently ignored, file is never attached

Expected: Windows absolute paths should be recognized.


Bug 2: send_message MEDIA fails due to restricted allowed roots

validate_media_delivery_path() in gateway/platforms/base.py rejects files outside the cache directories. Default MEDIA_DELIVERY_SAFE_ROOTS only includes cache dirs.

Workaround: Copy file to document_cache + use /c/Users/... Unix-style path.

Suggested fix: Add user home dir to allowed roots on Windows, or document HERMES_MEDIA_ALLOW_DIRS / gateway.media_delivery_allow_dirs in Windows docs.


Log evidence

2026-05-29 16:45:33 WARNING gateway.platforms.base: Skipping unsafe MEDIA directive path outside allowed roots
2026-05-29 20:57:50 WARNING gateway.platforms.base: Skipping unsafe MEDIA directive path outside allowed roots

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliverytype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions