Repository navigation
fix(media-server): validate each ranged download response - #3375
Open
vedanth-jadhav wants to merge 2 commits into
Open
vedanth-jadhav wants to merge 2 commits into
vedanth-jadhav wants to merge 2 commits into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Author
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Parallel source downloads validate the first response's range but trust later HTTP 206 parts based only on body length. A cache/proxy returning a different same-sized range is written at the requested offset and reported as a successful download, corrupting inputs used by Loom imports and direct video conversion. Oversized parts are also written past their declared range before the final length check rejects them.
Validate each subsequent part's
Content-Rangestart, end and total against the requested range and initial object size before reading it. Cancel rejected bodies. Check each streamed chunk against the remaining expected bytes before writing; cancel the reader when reading/writing fails. Existing full-stream/capped-range fallback, byte-for-byte assembly, If-Match requests and abort/drain handling remain in the same pipeline.Validation on Linux x86_64 / Bun 1.4.4:
noUncheckedIndexedAccess, Biome andgit diff --checkpass. Eleven existing resource-accounting tests also pass.Reproduce:
cd apps/media-server && bun test src/__tests__/lib/parallel-download.test.ts. Tests use local HTTP and injected streams, with no external media storage. Malformed later 206 responses now deliberately fail rather than being silently assembled; ordinary valid ranges remain byte-identical. No performance claim or new dependencies. Checked current main/open PRs; #3000 changes remote-URL access policy, while this change validates the bytes' placement.

Confidence Score: 5/5
The PR appears safe to merge; the follow-up addresses the previous coverage suggestion.Summary
The PR checks each ranged response before accepting its bytes and stops oversized bodies before they cross the declared boundary.
Reviews (2) · Last reviewed commit: "test(media-server): cover cumulative str..." · Reviewed by Greptile