Skip to content

fix: handle missing Content-Length header in download_file#371

Merged
bigcat88 merged 1 commit intomainfrom
fix-download-missing-content-length
Mar 12, 2026
Merged

fix: handle missing Content-Length header in download_file#371
bigcat88 merged 1 commit intomainfrom
fix-download-missing-content-length

Conversation

@bigcat88
Copy link
Contributor

download_file() crashes with a KeyError when the server response doesn't include a Content-Length header. This happens with chunked transfer encoding, which is common when servers apply gzip compression or when downloading from certain CDNs.

The fix uses .get() instead of direct dict access. When Content-Length is missing, the progress bar falls back to an indeterminate style instead of crashing.

This is the proper fix for the issue described in #242. That PR worked around it by forcing Accept-Encoding: identity on all downloads, which would disable compression and slow things down for everyone. This fix handles the root cause in download_file itself so all callers benefit.

Closes #242

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Mar 12, 2026
@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main     #371      +/-   ##
==========================================
+ Coverage   53.31%   53.36%   +0.05%     
==========================================
  Files          32       32              
  Lines        3588     3592       +4     
==========================================
+ Hits         1913     1917       +4     
  Misses       1675     1675              
Files with missing lines Coverage Δ
comfy_cli/file_utils.py 79.87% <100.00%> (+0.50%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bigcat88 bigcat88 merged commit 75cff8b into main Mar 12, 2026
14 checks passed
@bigcat88 bigcat88 deleted the fix-download-missing-content-length branch March 12, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant