Skip to content

fix: infer remaining bytes for multipart uploads - #224

Open
allenflux wants to merge 1 commit into
Comfy-Org:mainfrom
allenflux:fix/multipart-file-position
Open

allenflux wants to merge 1 commit into
Comfy-Org:mainfrom
allenflux:fix/multipart-file-position

Conversation

@allenflux

@allenflux allenflux commented Oct 18, 2026 •

Copy link
Copy Markdown

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.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Comfy-Org/comfy-python-sdk/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 70c5e242-5557-47e0-9389-a5f0eca79862
📥 Commits

Reviewing files that changed from the base of the PR and between 6d2dd72 and ee93cc6.

📒 Files selected for processing: 4
  • CHANGELOG.md
  • src/comfy_low/_multipart.py
  • tests/test_low_decoding.py
  • tests/test_multipart_upload.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Multipart size inference now counts bytes remaining from a stream’s current position. New tests cover size probing and synchronous and asynchronous uploads from partially read streams.

Changes: Multipart remaining-byte sizing

Layer / File(s) Summary
Calculate remaining stream size
src/comfy_low/_multipart.py, tests/test_low_decoding.py
file_size_of reports the nonnegative bytes remaining at the current position. Tests check disk files, memory streams, and pipes, including cursor preservation.
Validate multipart upload content
tests/test_multipart_upload.py, CHANGELOG.md
Synchronous and asynchronous upload tests check that uploaded content starts at the stream’s current position. The changelog records the Content-Length fix.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: wei-hai

Merge Risk: ⚪ Minimal · up to ee93c

The remaining-byte sizing change has no identified merge-blocking issue. Normal checks can proceed.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: inferring remaining bytes for multipart uploads.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@allenflux
allenflux marked this pull request as ready for review October 18, 2026 05:13
@allenflux
allenflux requested review from a team as code owners October 18, 2026 05:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant