[PR #224] fix: infer remaining bytes for multipart uploads #224

Open
opened 2026-10-31 22:02:28 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-python-sdk/pull/224
Author: @allenflux
Created: 10/18/2026
Status: 🔄 Open

Base: main ← Head: fix/multipart-file-position


📝 Commits (1)

  • ee93cc6 fix: infer remaining bytes for multipart uploads

📊 Changes

4 files changed (+106 additions, -4 deletions)

View changed files

📝 CHANGELOG.md (+5 -0)
📝 src/comfy_low/_multipart.py (+4 -4)
📝 tests/test_low_decoding.py (+35 -0)
➕ tests/test_multipart_upload.py (+62 -0)

📄 Description

A binary file already read or seeked past its start fails in ComfyLow.post_assets and AsyncComfyLow.post_assets when file_size is omitted: the multipart iterator sends from the current cursor, but the file-descriptor size probe declares the entire file length. For example, a ten-byte disk file read by four bytes raises Too little data for declared Content-Length; an equivalent BytesIO succeeds.

Infer the remaining bytes using the stream’s logical tell() position, preserving buffered-file cursor behavior. Clamp positions beyond EOF to zero and leave unseekable sizes unknown. Explicit file_size and the upload iterator are unchanged. Regression tests use real local HTTP uploads in both transports and check the received file part, plus raw/buffered/memory streams, EOF, and unseekable pipe controls.

Validation on Python 3.12.11/macOS:

  • Untouched base with the final regression tests: 16 failed, 17 passed; focused fixed suite: 64 passed.
  • Full suite: 1291 passed, 9 skipped (live gateway/Router tests require explicit environment configuration).
  • Ruff check/format, mypy, codegen drift, public repository hygiene, wheel/sdist build, and twine check pass.

No live gateway or Router calls were made. The Python 3.10–3.13 CI matrix remains to be run.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed multipart uploads from partially read files so the reported content length matches the bytes remaining to upload.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-python-sdk/pull/224 **Author:** [@allenflux](https://github.com/allenflux) **Created:** 10/18/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/multipart-file-position` --- ### 📝 Commits (1) - [`ee93cc6`](https://github.com/Comfy-Org/comfy-python-sdk/commit/ee93cc62b6bf907ec39516fbea305145a9dfde45) fix: infer remaining bytes for multipart uploads ### 📊 Changes **4 files changed** (+106 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+5 -0) 📝 `src/comfy_low/_multipart.py` (+4 -4) 📝 `tests/test_low_decoding.py` (+35 -0) ➕ `tests/test_multipart_upload.py` (+62 -0) </details> ### 📄 Description A binary file already read or seeked past its start fails in `ComfyLow.post_assets` and `AsyncComfyLow.post_assets` when `file_size` is omitted: the multipart iterator sends from the current cursor, but the file-descriptor size probe declares the entire file length. For example, a ten-byte disk file read by four bytes raises `Too little data for declared Content-Length`; an equivalent `BytesIO` succeeds. Infer the remaining bytes using the stream’s logical `tell()` position, preserving buffered-file cursor behavior. Clamp positions beyond EOF to zero and leave unseekable sizes unknown. Explicit `file_size` and the upload iterator are unchanged. Regression tests use real local HTTP uploads in both transports and check the received file part, plus raw/buffered/memory streams, EOF, and unseekable pipe controls. Validation on Python 3.12.11/macOS: - Untouched base with the final regression tests: 16 failed, 17 passed; focused fixed suite: 64 passed. - Full suite: 1291 passed, 9 skipped (live gateway/Router tests require explicit environment configuration). - Ruff check/format, mypy, codegen drift, public repository hygiene, wheel/sdist build, and twine check pass. No live gateway or Router calls were made. The Python 3.10–3.13 CI matrix remains to be run. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed multipart uploads from partially read files so the reported content length matches the bytes remaining to upload. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-python-sdk#224
No description provided.