reply_parameters silently dropped from multipart requests (sendVideo/sendPhoto with uploaded media) in 4.16.3 — fix exists but was never released
Context
This is essentially the same root cause as #1970, but I'm filing it with a concrete non-Context reproduction (telegram.sendVideo with an uploaded file) and, more importantly, an ask: the fix has existed for a long time (#1992, also included in #2092 via commit 877d9515) but no released version on npm contains it — latest is still 4.16.3.
Telegraf.js Version
4.16.3 (npm latest)
User OS
Linux (Node.js 20)
Minimal Example Code Reproducing the Issue
await bot.telegram.sendVideo(
chatId,
{ url: 'http://localhost:3000/uploads/some-video.mp4' }, // any InputFile that triggers an upload
{
caption: 'edited message notification',
parse_mode: 'HTML',
reply_parameters: { message_id: 2919 },
}
);Expected Behavior
The sent video is a reply to message 2919.
Current Behavior
The video is sent successfully, but not as a reply. No error, no warning — reply_parameters is silently discarded.
The same options object works fine with sendMessage (JSON request body) or when the media is passed as a plain URL string (also JSON body). The field is only lost when Telegraf switches to multipart/form-data because the media needs to be uploaded ({ url } / { source } input).
Root Cause
In src/core/network/client.ts, buildFormDataConfig only JSON-serializes the fields listed in FORM_DATA_JSON_FIELDS (results, reply_markup, mask_position, shipping_options, errors). reply_parameters is not in that list, so it reaches attachFormValue as a plain object; since it has no media/type/url/source props, it falls through to attachFormMedia, which finds nothing to attach and drops the field entirely.
This affects any object-valued field that isn't in FORM_DATA_JSON_FIELDS, e.g. link_preview_options as well.
Ask
Could #1992 / #2092 (commit 877d9515) be merged and published to npm? This bug silently breaks reply threading for every bot that uploads media, and the fix has been sitting unreleased for over a year.
Workaround for anyone hitting this
Pre-serialize the field yourself — Telegraf passes string fields through to the form untouched and the Bot API accepts JSON-encoded object fields in multipart requests:
reply_parameters: JSON.stringify({ message_id: 2919 }) as never,Related: #1970, #1992, #2092
Source: telegraf/telegraf