Skip to content

fix: filter InputFile objects from params in multipart requests - #364

Merged
The0xArchitect merged 1 commit into
theweaverlabs:mainfrom
devsdocs:fix/multipart-inputfile-upload
Jul 27, 2026
Merged

fix: filter InputFile objects from params in multipart requests#364
The0xArchitect merged 1 commit into
theweaverlabs:mainfrom
devsdocs:fix/multipart-inputfile-upload

Conversation

@devsdocs

Copy link
Copy Markdown
Contributor

Fixes multipart upload issue where InputFile.fromBytes() was causing Telegram API to reject requests with Bad Request error.

Root cause:

  • InputFile objects were being serialized as attach URL strings in form fields
  • This conflicted with the actual file bytes sent as multipart data
  • Telegram API rejected the duplicate/conflicting data for the same field

Solution:

  • Filter InputFile objects from params BEFORE jsonEncode in _sendMultipartRequest()
  • Only the actual file bytes are sent as multipart data
  • InputFile objects are handled separately via payload.files

Affected methods:

  • sendPhoto()
  • sendDocument()
  • sendAudio()
  • sendVideo()
  • sendMediaGroup()
  • All other methods using InputFile.fromBytes()

Testing:

  • Verified sendPhoto() with file bytes passes
  • Verified sendDocument() with file bytes passes
  • Verified sendMediaGroup() with multiple files passes
Fixes multipart upload issue where InputFile.fromBytes() was causing
Telegram API to reject requests with Bad Request error.

Root cause:
- InputFile objects were being serialized as attach URL strings in form fields
- This conflicted with the actual file bytes sent as multipart data
- Telegram API rejected the duplicate/conflicting data for the same field

Solution:
- Filter InputFile objects from params BEFORE jsonEncode in _sendMultipartRequest()
- Only the actual file bytes are sent as multipart data
- InputFile objects are handled separately via payload.files

Affected methods:
- sendPhoto()
- sendDocument()
- sendAudio()
- sendVideo()
- sendMediaGroup()
- All other methods using InputFile.fromBytes()

Testing:
- Verified sendPhoto() with file bytes passes
- Verified sendDocument() with file bytes passes
- Verified sendMediaGroup() with multiple files passes
@The0xArchitect
The0xArchitect merged commit d79192a into theweaverlabs:main Jul 27, 2026
1 check passed
@The0xArchitect

Copy link
Copy Markdown
Collaborator

Sorry for the delay, got caught up with a few other works. Thanks for the fix! Will push a new release soon!

@devsdocs
devsdocs deleted the fix/multipart-inputfile-upload branch July 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants