Conversation
Pulling a file from a URL failed with "request is missing ContentLength" whenever the response had no known length. That happens for chunked responses, and also for any gzip encoded response, because Go's HTTP client decompresses it transparently and reports the length as -1. raw.githubusercontent.com and pastebin both answer that way. Instead of rejecting these responses, Filesystem.Write now accepts a negative size meaning "unknown". The data is written to a hidden temporary file next to the target through the existing quota file, so the disk limit is enforced on every write, and it is only renamed over the target once the copy has finished. If the download does not fit or fails for any other reason, the temporary file is removed and an existing file at the target is left untouched. Downloads with a known length behave as before. Progress is only tracked when the total size is known. Fixes pelican#133
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📜 Recent review details🔇 Additional comments (4)
📝 WalkthroughWalkthroughThe downloader now accepts responses without a positive content length. The filesystem writes unknown-size streams under disk quotas and replaces existing files only after a successful write. ChangesUnknown-Length Downloads
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant Download as Download.Execute
participant Filesystem as Filesystem.Write
participant UnknownSize as writeUnknownSize
participant QuotaFile as quota-aware file
Download->>Filesystem: Stream response body with unknown size
Filesystem->>UnknownSize: Route negative newSize
UnknownSize->>QuotaFile: Copy data while checking quota
UnknownSize->>UnknownSize: Rename completed temporary file over target
Suggested reviewers: Merge Risk: ⚪ Minimal · up to Unknown-length downloads appear mergeable after normal checks; no concrete issue remains that warrants holding the change. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Unknown-length downloads remain subject to disk limits, but replacing an existing file can change its permissions. Concurrent replacements and interrupted downloads also present risks to quota accuracy and cleanup. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit watched the bytes flow by, Comment |
Fixes #133
raw.githubusercontent.com and pastebin gzip the response, Go decompresses it and reports the length as -1, so the downloader refused it. chunked responses hit the same check.
the check was there for the disk limit, so instead of dropping it
Filesystem.Writenow takes a negative size as unknown, writes to a temp file through the quota file and only renames it over the target once done. if it doesn't fit, the temp file goes away and the old file stays as it was. known-length downloads work like beforetests with an httptest server for gzip, chunked and over the limit
Summary by CodeRabbit