fix(relay): deliver media from Git Bash paths and legacy connectors on Windows - #78333
Open
AutomatteAsia wants to merge 1 commit into
Open
fix(relay): deliver media from Git Bash paths and legacy connectors on Windows#78333AutomatteAsia wants to merge 1 commit into
AutomatteAsia wants to merge 1 commit into
Conversation
…n Windows Two fixes for native-Windows media delivery: 1. Accept Git Bash style paths (/c/Users/... -> C:\Users\...) in media delivery. The Hermes terminal on Windows runs via the bundled Git Bash (MinGit), which reports paths in Unix format. Path.is_absolute() returns False for those (no drive letter), so validate_media_delivery_path rejected every file the agent named as 'unsafe'. Normalize in the three path consumers (validate_media_delivery_path, _normalize_media_tag_path, extract_local_files), guarded on the drive actually existing so POSIX-style paths (/r/a.png) are left untouched. 2. Fail open for send_media on legacy relay connectors. send_media was added after the supported_ops discovery field, so a legacy connector (empty supported_ops) can never advertise it even when it implements it, and the op-gated lane silently fell back to a text notice. Respect an explicit op declaration that excludes send_media, but attempt the op for legacy connectors and let a transport decline degrade to the same text fallback.
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.
Problem
On native Windows, Hermes cannot deliver files (e.g.
.pdf) to messaging platforms. The bundled Git Bash (MinGit) terminal reports paths in Unix format (/c/Users/...), and two code paths drop or reject the media:Git Bash paths fail the delivery gate.
validate_media_delivery_path()checksPath.is_absolute(), which returnsFalsefor/c/Users/...(no drive letter). Every file the agent names is rejected as "unsafe" and silently falls back to a text notice. The same rejection hits_normalize_media_tag_path()(MEDIA: tags) andextract_local_files()(bare paths in the reply).Relay connectors never advertise
send_media.send_mediawas added after thesupported_opsdiscovery field (Phase 1 feat(relay): Phase 1 parity — supported_ops discovery, wire identity fields, /handoff aliasing, provision displayName #71300 came before Phase 2 feat(relay): Phase 2 media parity — send_media egress + inbound media localization #71363). A legacy connector (emptysupported_ops) falls back toLEGACY_OPS = ("send", "edit", "typing", "follow_up"), which omitssend_media- so the op-gated media lane is never attempted, even when the connector implements it.Fix
Normalize Git Bash paths in the three path consumers -
validate_media_delivery_path,_normalize_media_tag_path,extract_local_files. Onos.name == "nt", convert/c/Users/...?C:\Users\.... The conversion is guarded on the drive letter actually existing (os.path.isdir("C:\\")), so genuine POSIX-style paths like/r/a.pngare left untouched.Fail open for
send_mediaon legacy connectors. Respect an explicit op declaration that excludessend_media(the caller falls back to text, unchanged), but for legacy connectors (emptysupported_ops- which predate the discovery field and can therefore never advertise the op even when they implement it), attempt the lane and let a transport decline degrade to the same text fallback.Verification
main: Git Bash path rejected byvalidate_media_delivery_path; relaysend_mediagated out for emptysupported_ops./c/Users/...validates, extracts via MEDIA: tag and bare-path detection, and resolves to the real file; nativeC:\...paths behave unchanged.tests/gateway/relay/test_relay_media.py(12/12),test_media_tag_formatting_variants.py,test_media_tag_cleanup.py,test_media_extraction.pyall green. The 6 remaining failures in the media suite are pre-existing Windows-vs-POSIX path-format assertions that also fail on cleanmainwithout this change.