fix(modelscope): validate ranged responses#1933
Open
NelZyhh wants to merge 2 commits into
Open
Conversation
Signed-off-by: zhangyh66 <zhangyh66@chinatelecom.cn>
NelZyhh
requested review from
BruceAko,
ClementMaH,
CooooolFrog,
yxxhero and
yyzai384
July 18, 2026 03:32
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1933 +/- ##
==========================================
+ Coverage 47.21% 47.26% +0.05%
==========================================
Files 94 94
Lines 24214 24356 +142
==========================================
+ Hits 11432 11512 +80
- Misses 12782 12844 +62
🚀 New features to boost your workflow:
|
Signed-off-by: zhangyh66 <zhangyh66@chinatelecom.cn>
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.
Related Issue
Summary
206 Partial ContentContent-Rangeexists and matches the requested byte interval200 OK + full bodycase on range requestsBackground
When downloading
modelscope://files by pieces, the client previously treated any2xxresponse as success.If a ranged request unexpectedly returned a full body response, the client could still write the first
Nbytes to a non-zero offset.This could produce files with the correct size but corrupted content.
A real reproduction showed:
4194304content were identicalRoot Cause
The ModelScope backend propagated the
Rangerequest header, but it did not validate:206 Partial ContentContent-Rangeheader is presentContent-Rangestart/end matches the requested rangeAs a result, an invalid ranged response could pass through as a successful piece download.
Changes
validate_range_response()indragonfly-client-backend/src/model_scope.rs206 Partial Contentfor ranged requestsContent-Rangefor ranged requestsContent-Range200 OK + full bodyfor a range requestTesting
cargo fmt --checkContent-Range200 OK + full bodycargo check --all --all-targetsandcargo clippy --all-targets -- -D warningswere blocked earlier by a broken local Rust 1.88.0 toolchain; the toolchain has been repaired and the full checks are being rerun