Skip to content

fix(gateway): support Windows absolute paths in MEDIA tag regexes#35388

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-f3008ab5
May 30, 2026
Merged

fix(gateway): support Windows absolute paths in MEDIA tag regexes#35388
teknium1 merged 3 commits into
mainfrom
hermes/hermes-f3008ab5

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Windows file and screenshot delivery through the gateway now works — MEDIA:C:\Users\...\file.pdf (and C:/...) extract and upload, where previously they matched none of the MEDIA path regexes and were silently dropped.

Root cause: all four MEDIA path regexes anchored to POSIX roots only ((?:~/|/)), ignoring Windows drive letters and backslash separators.

Salvage of #35161 by @Tranquil-Flow, cherry-picked onto current main with authorship preserved. Closes #35270, #34632.

Changes

  • gateway/platforms/base.py: add [A-Za-z]:[/\\] anchor to MEDIA_TAG_CLEANUP_RE and extract_local_files path_re; widen extract_local_files separators /[/\\] so it traverses Windows directory trees.
  • gateway/run.py: add the same anchor to both _TOOL_MEDIA_RE patterns (history-scan + result-scan).
  • Tests: tests/gateway/test_platform_base.py (Windows path cases), new tests/gateway/test_run_tool_media_re.py.

Validation

Before After
MEDIA:C:\...\f.pdf extract dropped uploads
MEDIA:C:/.../f.pdf extract dropped uploads
Unix /... and ~/... works works (no regress)
Relative win path (no drive) ignored ignored
Unknown-ext tag falls through falls through (black-hole guard intact)

E2E (real worktree imports, all 4 sites): 19/19. Targeted suite (platform_base, run_tool_media_re, media_extraction, stream_consumer): 255 passed.

Infographic

windows-media-paths-fixed

Tranquil-Flow and others added 2 commits May 30, 2026 07:15
…xtract_local_files (#34632)

The MEDIA_TAG_CLEANUP_RE and extract_local_files path regex both used
(?:~/|/) to anchor paths, which only matches Unix-style absolute and
home-relative paths. Two additional _TOOL_MEDIA_RE patterns in run.py
had the same limitation. Windows absolute paths (C:\Users\..., D:/...)
were silently ignored, causing MEDIA directive delivery to fail.

Add [A-Za-z]:[/\\] as a third anchor alternative in all four regex
locations (base.py x2, run.py x2). Also update path separators in
extract_local_files from / to [/\\] so it can traverse Windows
directory trees.

Revert accidental + quantifier in MEDIA_TAG_CLEANUP_RE lookahead
that changed match-one to match-one-or-more (unrelated to fix).

Fixes: #34632
@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-f3008ab5 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9508 on HEAD, 9507 on base (🆕 +1)

🆕 New issues (1):

Rule Count
unresolved-import 1
First entries
tests/gateway/test_run_tool_media_re.py:20: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`

✅ Fixed issues: none

Unchanged: 4931 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

…ehavior

test_windows_path_not_matched asserted the pre-fix POSIX-only behavior.
The Windows drive-letter support now intentionally matches these paths,
so replace it with parametrized positive cases plus a relative-path
negative guard, mirroring tests/gateway/test_platform_base.py.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gateway extract_media and extract_local_files fail to parse Windows file paths

3 participants