fix(gateway): support Windows absolute paths in MEDIA tag regexes#35388
Merged
Conversation
…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
Contributor
🔎 Lint report:
|
| 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.
This was referenced May 30, 2026
fix(gateway): support Windows drive letters and backslashes in file path regex (fixes #35270)
#35328
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Windows file and screenshot delivery through the gateway now works —
MEDIA:C:\Users\...\file.pdf(andC:/...) 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
mainwith authorship preserved. Closes #35270, #34632.Changes
gateway/platforms/base.py: add[A-Za-z]:[/\\]anchor toMEDIA_TAG_CLEANUP_REandextract_local_filespath_re; widenextract_local_filesseparators/→[/\\]so it traverses Windows directory trees.gateway/run.py: add the same anchor to both_TOOL_MEDIA_REpatterns (history-scan + result-scan).tests/gateway/test_platform_base.py(Windows path cases), newtests/gateway/test_run_tool_media_re.py.Validation
MEDIA:C:\...\f.pdfextractMEDIA:C:/.../f.pdfextract/...and~/...E2E (real worktree imports, all 4 sites): 19/19. Targeted suite (platform_base, run_tool_media_re, media_extraction, stream_consumer): 255 passed.
Infographic