fix(gateway): map Docker MEDIA paths through bind mounts - #27779
Conversation
Resolve outbound MEDIA file paths emitted from Docker terminal sandboxes by translating configured bind-mounted container paths back to host-visible paths before gateway delivery. Add regression coverage for mapped paths, common Docker volume options, path-boundary handling, existing host-visible files, and malformed volume config.
3fcea68 to
e0faa47
Compare
|
Thanks for the focused bug fix. I verified the premise still holds on current main: gateway MEDIA extraction currently appends the literal expanded path at gateway/platforms/base.py:2972, while the Docker gateway startup path only warns about risky media delivery at gateway/run.py:2274-2318. Problems
Suggested changes
This is an automated hermes-sweeper review. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused Docker gateway fix. The underlying gap is still present on current main: extract_media() retains the literal container path at gateway/platforms/base.py:3658, and dispatch validates that path on the host at gateway/platforms/base.py:4927.
Problems
- The extraction hunk predates the current parser. Current main masks protected/JSON spans and has a separate extensionless-MEDIA path at
gateway/platforms/base.py:3645-3696; salvage must preserve those flows rather than replace the old extraction line directly. - Current main deliberately skips crafted paths when
expanduser()fails atgateway/platforms/base.py:3657-3662. The resolver fallback in the proposedgateway/media_paths.pyreturns the malformed original path instead, conflicting with the regression contract attests/gateway/test_platform_base.py:1801-1806.
Suggested changes
- Wire bind-mount translation into both current extraction paths before host validation, while retaining the current masking and failure behavior.
- Add the Docker mapping cases to the current parser test surface in
tests/gateway/test_platform_base.py, including extensionless directives and the existing crafted-null-path invariant.
This is an automated hermes-sweeper review.
| path = path.lstrip("`\"'").rstrip("`\"',.;:)}]") | ||
| if path: | ||
| media.append((os.path.expanduser(path), has_voice_tag)) | ||
| media.append((resolve_outbound_media_path(path), has_voice_tag)) |
There was a problem hiding this comment.
This replacement targets the pre-current extraction loop. Please salvage the resolver into current main's masked known-extension and extensionless passes (gateway/platforms/base.py:3645-3696) while preserving the current skip-on-expanduser()-failure behavior.
|
Closing with credit: you were the FIRST to submit a fix for the outbound container-path MEDIA delivery bug (May 18, well before the tracking issues existed). The fix merged via #81746 (merge commit 238351a) used #37207's mount-derived approach as the salvage base — it translates at the existing |
What does this PR do?
Fixes outbound
MEDIA:/container/pathdelivery when Hermes uses a Docker terminal backend but the messaging gateway sends files from the host process.Before this PR, an agent running in Docker could create a file under a bind-mounted container path (for example
/agent-artifacts/report.pdf) and reply withMEDIA:/agent-artifacts/report.pdf, but the host gateway would look for that container path on the host and fail. This PR maps configured Docker bind mounts back to host-readable paths before platform delivery.The approach is centralized and conservative:
terminal.docker_volumes/TERMINAL_DOCKER_VOLUMES.MEDIA:paths unchanged.Related Issue
No dedicated tracking issue.
Related PRs:
MEDIA:paths may fail and recommends host-visible paths.Duplicate check found no upstream PR implementing automatic outbound bind-mount mapping for
MEDIA:delivery.Type of Change
Changes Made
gateway/media_paths.pygateway/run.py,gateway/platforms/base.py,gateway/platforms/telegram.pyhermes_cli/config.pydocker_volumesinline guidance to document mounted container paths for gateway media delivery.website/docs/user-guide/configuration.md/outputis a convention, not a requirement.website/docs/user-guide/messaging/telegram.mdtests/gateway/test_send_image_file.pytests/gateway/test_runner_startup_failures.pyHow to Test
Manual reproduction path:
/agent-artifacts/report.pdf.MEDIA:/agent-artifacts/report.pdf./home/user/.hermes/cache/documents/report.pdf.Commands run locally:
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/Adocker_volumesdocs/comments changed.CONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A — this PR does not add or modify a skill.
Screenshots / Logs
Focused regression tests:
Independent read-only Codex review verdict: accept, no blocking issues.