fix(core): check start offset <= end offset#7340
Closed
dentiny wants to merge 8 commits intoapache:mainfrom
Closed
fix(core): check start offset <= end offset#7340dentiny wants to merge 8 commits intoapache:mainfrom
dentiny wants to merge 8 commits intoapache:mainfrom
Conversation
d90fae8 to
2b8a1ac
Compare
2b8a1ac to
d88df34
Compare
Xuanwo
reviewed
Mar 31, 2026
| // <range-start>-<range-end> | ||
| let start: u64 = v[0].parse().map_err(parse_int_error)?; | ||
| let end: u64 = v[1].parse().map_err(parse_int_error)?; | ||
| if end < start { |
Member
There was a problem hiding this comment.
How about we change the API of BytesRange too?
Contributor
Author
There was a problem hiding this comment.
Sounds good, I change From<T> into a Result<>-returned API from_range.
Xuanwo
reviewed
Mar 31, 2026
| where | ||
| T: RangeBounds<u64>, | ||
| { | ||
| fn from(range: T) -> Self { |
Member
There was a problem hiding this comment.
This change is a super large change as many of our API depends on this.
And I also think we don't need to change this. Rust API is clear that "It is empty if start >= end."
We can follow the same pattern. Downstream caller can check and return empty results.
Contributor
Author
|
I will redo this PR later when I got some time, it's not a big issue. |
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.
Which issue does this PR close?
Closes #7337
Rationale for this change
Start offset <= end offset is the precondition that for any valid ranges, I found opendal panics when giving an invalid input range.
What changes are included in this PR?
This PR does check for all range inputs that I'm aware of, and return error (if possible) and assertion failure (if returning error is not easy).
Are there any user-facing changes?
No.
AI Usage Statement
The bug was found by opus 4.6 chaos test, and it figure out all the code pointers I need to update.