fix(telegram): preserve original filename for inbound document/audio/video#31837
Merged
steipete merged 1 commit intoopenclaw:mainfrom Mar 2, 2026
Merged
Conversation
…o/video uploads The downloadAndSaveTelegramFile inner function only used the server-side file path (e.g. "documents/file_42.pdf") or the Content-Disposition header (which Telegram doesn't send) to derive the saved filename. The original filename provided by Telegram via msg.document.file_name, msg.audio.file_name, msg.video.file_name, and msg.animation.file_name was never passed through, causing all inbound files to lose their user-provided names. Now downloadAndSaveTelegramFile accepts an optional telegramFileName parameter that takes priority over the fetched/server-side name. The resolveMedia call site extracts the original name from the message and passes it through. Closes openclaw#31768 Made-with: Cursor
Contributor
Greptile SummaryPreserves original Telegram filenames for document/audio/video attachments by passing Key changes:
Verified:
Confidence Score: 5/5
Last reviewed commit: ee4832c |
steipete
added a commit
that referenced
this pull request
Mar 2, 2026
Contributor
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.
Summary
business-plan.pdf) is lost and replaced by the Telegram server-side name (e.g.file_42.pdf).downloadAndSaveTelegramFilenow accepts an optionaltelegramFileNameparameter.resolveMediaextractsfile_namefrommsg.document,msg.audio,msg.video, andmsg.animation, and passes it through. The resolution order is: Telegram metadata → fetch response → server path.fetchRemoteMedia,saveMediaBuffer, or any other media pipeline. Photo handling is unchanged (photos don't carryfile_name).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Inbound Telegram documents, audio files, videos, and animations now retain their original filename when saved locally, instead of being renamed to the Telegram server-side path.
Security Impact (required)
NoNoNoNoNoRepro + Verification
Environment
Steps
business-plan.pdfto the bot via TelegramExpected
business-plan.pdf(or a sanitized variant)Actual (before fix)
file_42.pdf(Telegram server-side name)Evidence
delivery.resolve-media-retry.test.tspassHuman Verification (required)
pnpm test -- --run src/telegram/bot/delivery.resolve-media-retry.test.ts— all passfile_nameis absent (usesfetched.fileName); fallback when both are absent (usesfilePath); each media type (document, audio, video) tested individuallyCompatibility / Migration
YesNoNoFailure Recovery (if this breaks)
telegramFileNameparameter is optional and defaults to the previous behaviorsrc/telegram/bot/delivery.resolve-media.tsundefinedin saved mediaRisks and Mitigations
file_namecould contain path separators or special characterssaveMediaBufferalready sanitizes filenames downstream; this change only passes the name through🤖 AI-assisted (Claude) · Fully tested · I understand what this code does.