Repository navigation
fix(core): make BytesRange Display total for unrepresentable ranges - #8433
Open
Mola-maker wants to merge 1 commit into
Open
Mola-maker wants to merge 1 commit into
Mola-maker wants to merge 1 commit into
Conversation
This branch has not been 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.
Closes #8386.
Rationale for this change
DisplayforBytesRangereturnsErrfor zero-size ranges and for ranges whose end overflowsu64.format!turns aDisplayfailure into a panic, soBytesRange::new(0, Some(0)).to_string()panics.Displaymust stay total: it may only fail when the underlying formatter fails.What changes are included in this PR?
Displaynow renders ranges with no valid HTTP representation (zero size, overflowing end) as an empty string instead of returningErr; all representable ranges render exactly as before.to_headernow builds from that rendering and returns an empty string for unrepresentable ranges, exactly as before, so no service's observable header behavior changes.Displayfails;to_headertests are unchanged.BytesRangedocs.Are there any user-facing changes?
Yes, minor:
BytesRange::to_string()(andformat!) no longer panics for zero-size or overflowing ranges; it returns"".to_header()output is unchanged.Breaking changes
None.
AI Usage Statement
format!panic with a std-only experiment, implemented the fix and updated the tests, and rancargo test -p opendal-core --lib types::bytes_range(17 passed) andcargo clippy -p opendal-core --lib(clean). The human contributor directed the work, selected the issue, and remains responsible for the change. Assumptions and unknowns affecting review: (1) rendering unrepresentable ranges as""is the chosen fix; the alternative of keepingDisplayfailing and relying onto_headeris what the issue reports as incorrect; (2) full workspace CI (clippy --workspace, nextest) still has to run on this PR; (3) a contributor verbally claimed this issue on 2026-10-11 but had no linked PR as of 2026-10-26.