Xuanwo opened a new pull request, #8943:
URL: https://github.com/apache/opendal/pull/8943
# Which issue does this PR close?
Fixes the `hf` XET ranged-read regression introduced after upgrading
`hf-xet` to `1.8.1` in #8778.
# Rationale for this change
`xet-data` 1.8.0+ (pulled in by `hf-xet` 1.8.1 in #8778) rejects ranges with
`start > 0 && start >= file_size` inside `download_stream` with
`DataError::ParameterError`. `HfReadStream::new_xet` mapped all
`download_stream` errors to `ErrorKind::Unexpected` before `CompleteLayer`
could classify out-of-bounds reads, causing `behavior::test_read_limit` to fail
on both `hf_bucket` and `hf_dataset` (while `hf_bucket_http` passed via HTTP
416 -> `ErrorKind::RangeNotSatisfied`).
# What changes are included in this PR?
- Update `xet_range` in `core/services/hf/src/reader.rs` to accept
`file_size: u64` and return `Result<Option<Range<u64>>>`:
- Return `ErrorKind::RangeNotSatisfied` for non-empty forward ranges whose
`offset >= file_size` (including empty objects with a non-zero size and
open-ended forward ranges at or beyond EOF).
- Use `saturating_add` when computing bounded range ends, map zero-length
ranges to `0..0`, and convert suffix ranges against `file_size`.
- Validate the range with `xet_range(range, size)?` in
`HfReadStream::new_xet`.
- Expand `test_xet_range_conversion` for boundary, overflow, empty-file,
zero-length, and suffix cases, and add an ignored live test
`test_read_xet_range_out_of_bounds` covering short-tail and out-of-bounds XET
reads against the public `google-research-datasets/mbpp` dataset.
# Are there any user-facing changes?
Out-of-bounds XET ranged reads on the `hf` service now return
`ErrorKind::RangeNotSatisfied` instead of `ErrorKind::Unexpected`, matching
HTTP download mode and OpenDAL's read range contract.
# Breaking changes
# AI Usage Statement
- Harness: pi
- Model: Gemini 4 Neon
- Effort: high
- Role: Implemented the `xet_range` bounds check and tests, reproduced the
`ErrorKind::Unexpected` failure against the live public Hugging Face dataset
(`google-research-datasets/mbpp`) in XET mode before the fix, and verified
`ErrorKind::RangeNotSatisfied` against the same live dataset after the fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]