← Back to PRs

#12381: fix(telegram): preserve original filename for inbound documents

by thebtf open 2026-02-09 06:18 View on GitHub →
channel: telegram size: XS
## Summary Telegram inbound documents lose their original filename when saved to disk. ## Steps to reproduce 1. Send a document to a Telegram bot (e.g. `my-report.pdf`) 2. Check the saved file in `~/.openclaw/media/inbound/` 3. File is saved as `file_12345---{uuid}.pdf` instead of `my-report---{uuid}.pdf` ## Expected behavior The original filename from the Telegram message should be preserved in the saved file path, using the existing `{sanitized}---{uuid}.ext` naming scheme that `saveMediaBuffer()` already supports. ## Actual behavior `resolveMedia()` passes `fetched.fileName ?? file.file_path` to `saveMediaBuffer()`. Since: - `fetched.fileName` comes from HTTP `Content-Disposition` header, which Telegram API does **not** set → always `undefined` - `file.file_path` is Telegram internal path (e.g. `documents/file_12345.pdf`) The original filename (`msg.document.file_name`) is never read. ## Fix One-line priority change: read `msg.document?.file_name` / `msg.audio?.file_name` / `msg.video?.file_name` before falling back to `fetched.fileName` and `file.file_path`. The `saveMediaBuffer()` infrastructure for embedding original filenames already works correctly — this fix simply provides the right value. ## Related Analogous to #5781 / #10862 (WhatsApp document filename issues) but for the Telegram inbound path. ## Testing - [x] `pnpm build` passes - [x] All existing tests pass (26/26 in delivery + store + download) - [x] AI-assisted (analysis + fix), manually verified code path --- 🤖 AI-assisted PR --- ## Validation - [x] `pnpm build` — passes - [x] `pnpm check` — passes - [x] `pnpm test` — 26/26 delivery + store + download tests pass ## Contribution checklist - [x] **Focused scope**: One-line priority change for filename resolution - [x] **What + why**: described above - [x] **AI-assisted**: Yes, already marked as "AI-assisted PR". Testing level: fully tested (26 existing tests pass)

Most Similar PRs