fix(gateway): keep Discord docs out of photo vision routing - #26409
Closed
LeonSGP43 wants to merge 1 commit into
Closed
fix(gateway): keep Discord docs out of photo vision routing#26409LeonSGP43 wants to merge 1 commit into
LeonSGP43 wants to merge 1 commit into
Conversation
Collaborator
Contributor
|
Merged via PR #53923 (commit 505bc27d) — #53923 Salvaged onto current main with both bugs fixed (mixed-attachment per-attachment routing + uncommon-format transcode), plus the document-context-note path widened so a doc mixed into a photo message reaches the agent as a readable file. Your work was combined with two other independent fixes for this issue and all three contributors are credited in the PR; @shashwatgokhe's authorship is preserved on the merge commit. Thanks for the fix. |
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.
What does this PR do?
Fixes the mixed-attachment half of #25935. When a Discord message contains both images and documents, Hermes currently treats every attachment as an image if the message-level type is
PHOTO. That causes non-image files like.mdto be forwarded into the vision image path and can trigger provider-sideCould not process image400s.This patch narrows the fallback: Hermes now trusts each attachment's own MIME type first, and only falls back to the message-level
PHOTOclassification when that attachment has no per-file MIME metadata.Related Issue
Addresses #25935
Type of Change
Changes Made
gateway/run.pyto classify inbound media per attachment, so document attachments on Discord photo messages no longer enter the image routing / vision path.tests/gateway/test_native_image_buffer_isolation.pycovering mixed image+document photo messages.How to Test
python3 -m pytest -o addopts='' tests/gateway/test_native_image_buffer_isolation.py.MessageType.PHOTOevent withmedia_types=["image/png", "text/markdown"]only buffers the image path for native vision delivery..mdattachment as a file, instead of marking both as images.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — N/Acli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs
python3 -m pytest -o addopts='' tests/gateway/test_native_image_buffer_isolation.py→4 passed in 0.35spython3 -m py_compile gateway/run.py tests/gateway/test_native_image_buffer_isolation.pygit diff --checktests/gateway/test_discord_document_handling.pyis red in this environment before/after the patch because current Discord attachment tests hit existing SSRF URL blocking againsthttps://cdn.discordapp.com/attachments/fake/file; not caused by this change.