Skip to content

fix(eve): prefer known Telegram attachment media type over HTTP content-type - #1218

Open
harlley wants to merge 1 commit into
vercel:mainfrom
harlley:fix/telegram-attachment-media-type
Open

fix(eve): prefer known Telegram attachment media type over HTTP content-type#1218
harlley wants to merge 1 commit into
vercel:mainfrom
harlley:fix/telegram-attachment-media-type

Conversation

@harlley

@harlley harlley commented Jul 25, 2026

Copy link
Copy Markdown

Closes #1217.

Description

When a photo is sent to a Telegram-channelled eve agent, createTelegramFetchFile resolves the file's media type by prioritizing the HTTP content-type header from Telegram's file-download endpoint over the media type the channel already knows from the inbound message. Telegram's file endpoint frequently responds with application/octet-stream (or no content-type) for photos, so vision models receive mediaType: "application/octet-stream" and cannot recognize the image. With an uploadPolicy: { allowedMediaTypes: ["image/*"] }, the photo is rejected before it ever reaches the model:

Telegram file rejected — photo.jpg has media type "application/octet-stream"
which is not allowed by this route. Allowed: image/*.

The fix inverts the priority so ref.mediaType (the known attachment type, e.g. image/jpeg for photos) wins, falling back to the HTTP content-type and then application/octet-stream.

How did you test your changes?

Ran the Telegram attachments unit tests against the eve package:

cd packages/eve
pnpm run build:compiled
pnpm exec vitest run --config vitest.unit.config.ts \
  src/public/channels/telegram/attachments.test.ts
  • With the fix: all 4 tests pass.

  • Without the fix (reverted to main): the new regression test fails with the exact production error string:

    FAIL  ... > prefers the known attachment media type over the HTTP content-type header
    Error: Telegram file rejected — photo.jpg has media type "application/octet-stream"
    which is not allowed by this route. Allowed: image/*.
    

    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 a file_path) and the file download (returning a body with Content-Type: application/octet-stream), then asserts the resolved mediaType is image/jpeg — the type the channel already knew from the inbound photo.

PR Checklist

  • I linked an issue with prior discussion confirming this change is wanted — Telegram channel serves wrong media type for photos (breaks vision models) #1217
  • I ran the relevant checks from CONTRIBUTING.md (unit tests for the touched file; see commands above)
  • I added tests — regression test in attachments.test.ts
  • I added a changeset — .changeset/telegram-attachment-media-type.md (eve: patch)
  • DCO sign-off passes for every commit (git commit --signoff) — commit is signed and GitHub-verified (SSH signing key)

…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>
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

@harlley is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram channel serves wrong media type for photos (breaks vision models)

1 participant