Xuanwo opened a new pull request, #8809:
URL: https://github.com/apache/opendal/pull/8809

   # Which issue does this PR close?
   
   No issue was filed for this focused core fix; the included regression tests 
reproduce the defect directly.
   
   # Rationale for this change
   
   `PositionReader::open` and `PositionReader::read` did not check whether the 
input `BytesRange` was a suffix range (`BytesRange::Suffix`). Because 
`BytesRange::offset()` returns `0` and `BytesRange::size()` returns 
`Some(size)` for a suffix range, and `PositionRead` does not know the object's 
content length, `PositionReader` silently treated `BytesRange::suffix(n)` as 
the forward range `0..n` and returned prefix bytes instead of suffix bytes.
   
   `PositionReader`-backed services (`fs`, `compfs`, `hdfs`, `monoiofs`, `smb`) 
do not advertise `Capability::read_with_suffix`. Under the default 
`auto-simulate` feature, `SimulateReader` resolves suffix ranges into absolute 
forward ranges before delegating to `PositionReader`. However, when 
`SimulateLayer` is disabled (for example with `default-features = false` or 
`SimulateLayer::with_read_with_suffix(false)`) or when `PositionReader` is 
invoked directly, passing a suffix range silently corrupted reads by returning 
the file prefix.
   
   # What changes are included in this PR?
   
   - Require `BytesRange::Range` in `PositionReader::open` and 
`PositionReader::read`, returning `ErrorKind::Unsupported` for suffix ranges 
before touching the underlying `PositionRead` handle.
   - Pass resolved `(offset, size)` directly to `PositionReadStream::new` 
instead of `BytesRange`.
   - Add unit tests covering suffix range rejection (`open` and `read`, 
ensuring the underlying `PositionRead` is not opened or called) and forward 
range reads (`0..4`, `4..`, `..`).
   
   # Are there any user-facing changes?
   
   Calling `PositionReader` (or a `PositionReader`-backed service without 
suffix simulation enabled) with a suffix range now fails with 
`ErrorKind::Unsupported` instead of silently returning prefix bytes. Suffix 
reads through `Operator` with `SimulateLayer` enabled continue to work as 
before.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: Pi
   - Model: Gemini 4 Neon
   - Effort: high
   - Role: Audited `PositionReader`, `SimulateLayer`, `CompleteLayer`, and 
`PositionReader`-backed services (`fs`, `compfs`, `hdfs`, `monoiofs`, `smb`), 
implemented the fix and regression tests, and ran core unit, clippy, 
formatting, and local `fs` suffix behavior tests.
   


-- 
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]

Reply via email to