fix(eve): prefer known Telegram attachment media type over HTTP content-type - #1218
Open
harlley wants to merge 1 commit into
Open
fix(eve): prefer known Telegram attachment media type over HTTP content-type#1218harlley wants to merge 1 commit into
harlley wants to merge 1 commit into
Conversation
…nt-type Telegram's file endpoint frequently returns application/octet-stream (or no content-type) for photos. The channel already knows the attachment's media type from the inbound message (image/jpeg for photos), but createTelegramFetchFile prioritized the HTTP content-type header over that known type, so vision models received application/octet-stream and could not recognize the image. Invert the priority so the known ref.mediaType wins, falling back to the HTTP content-type and then application/octet-stream. Add a regression test that downloads a photo whose HTTP response is application/octet-stream and asserts the result mediaType stays image/jpeg. Signed-off-by: Harlley Oliveira <harlley@gmail.com>
Contributor
|
@harlley is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
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.
Closes #1217.
Description
When a photo is sent to a Telegram-channelled eve agent,
createTelegramFetchFileresolves the file's media type by prioritizing the HTTPcontent-typeheader from Telegram's file-download endpoint over the media type the channel already knows from the inbound message. Telegram's file endpoint frequently responds withapplication/octet-stream(or no content-type) for photos, so vision models receivemediaType: "application/octet-stream"and cannot recognize the image. With anuploadPolicy: { allowedMediaTypes: ["image/*"] }, the photo is rejected before it ever reaches the model:The fix inverts the priority so
ref.mediaType(the known attachment type, e.g.image/jpegfor photos) wins, falling back to the HTTPcontent-typeand thenapplication/octet-stream.How did you test your changes?
Ran the Telegram attachments unit tests against the
evepackage:With the fix: all 4 tests pass.
Without the fix (reverted to
main): the new regression test fails with the exact production error string:This confirms the test guards the regression: it fails on the old behavior and passes on the fixed one.
The regression test mocks Telegram's
getFile(returning afile_path) and the file download (returning a body withContent-Type: application/octet-stream), then asserts the resolvedmediaTypeisimage/jpeg— the type the channel already knew from the inbound photo.PR Checklist
CONTRIBUTING.md(unit tests for the touched file; see commands above)attachments.test.ts.changeset/telegram-attachment-media-type.md(eve: patch)git commit --signoff) — commit is signed and GitHub-verified (SSH signing key)