fix: telegram media blocks reject valid URL strings and file_ids#3474
fix: telegram media blocks reject valid URL strings and file_ids#3474MaxwellCalkin wants to merge 1 commit intosimstudioai:mainfrom
Conversation
The telegram_send_photo, telegram_send_video, telegram_send_audio, and telegram_send_animation blocks always routed media params through normalizeFileInput(), which JSON.parse's string inputs and returns undefined when parsing fails. This caused plain URL strings and Telegram file_id strings (both valid per the Telegram Bot API) to be silently dropped, resulting in "Photo is required." even when a valid URL was provided. Extract a resolveTelegramMedia() helper that passes plain strings through directly and only delegates to normalizeFileInput when the value is a serialized JSON object/array or a non-string value. Fixes simstudioai#3220 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR SummaryLow Risk Overview Adds Written by Cursor Bugbot for commit 13510d7. This will update automatically on new commits. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR fixes a bug where Telegram media blocks ( The fix introduces a scoped Key points:
Confidence Score: 4/5
|
Summary
Fixes #3220
The `telegram_send_photo`, `telegram_send_video`, `telegram_send_audio`, and `telegram_send_animation` blocks always route media parameters through `normalizeFileInput()`, which attempts to `JSON.parse()` string inputs and returns `undefined` when parsing fails. This causes plain URL strings (e.g. `https://example.com/photo.jpg\`) and Telegram file_id strings to be silently dropped, producing "Photo is required." even when a valid, publicly accessible URL is provided.
The Telegram Bot API natively accepts both URL strings and file_id strings for media parameters — they don't need to be file objects.
Root cause
In `normalizeFileInput()` (blocks/utils.ts):
```ts
if (typeof fileParam === 'string') {
try {
fileParam = JSON.parse(fileParam) // fails for plain URLs
} catch {
return undefined // <-- drops the valid URL
}
}
```
Fix
Extract a `resolveTelegramMedia()` helper that:
This is scoped to the Telegram block only — no changes to the shared `normalizeFileInput()` utility, so no risk to other integrations.
Test plan
This PR was authored by Claude Opus 4.6 (AI), operated by @MaxwellCalkin