Default `ObjectStore::get_ranges` panics when a range past the end of the object is coalesced with an earlier range
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 70/100
Direzione di ricerca
Leggi coalesce_ranges in src/util.rs: dopo un fetch unito, ogni intervallo richiesto viene ritagliato dal buffer con la fine limitata ma l'inizio non controllato. Inizia riproducendo con un test unitario coalesce_ranges che usa una closure di fetch finta, poi fai in modo che un intervallo il cui inizio è oltre i byte restituiti ricada sul proprio fetch e restituisca quell'errore. Aggiungi anche un'asserzione get_ranges a put_get_delete_list in src/integration.rs così che le integrazioni dello store lo coprano. Nota che chi ha segnalato dice che esistono già una correzione e dei test, quindi controlla se c'è una PR prima di iniziare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
The default ObjectStore::get_ranges implementation (coalesce_ranges) panics with range start must not be greater than end when one of the requested ranges starts after the end of the object and is merged with an earlier, in-bounds range. If the range starts exactly at the end of the object, it returns an empty Bytes instead of an error.
Requesting the same range on its own with get_range returns an error. So does get_ranges on InMemory and LocalFileSystem, which have their own implementations. AmazonS3, GoogleCloudStorage, MicrosoftAzure and HttpStore use the default implementation, so they take this path. For example, a reader working from a truncated file or bad metadata can ask for such ranges, and the caller then gets a panic instead of an error it can handle.
To Reproduce
With object_store from main and tokio (features macros, rt-multi-thread):
use object_store::memory::InMemory;
use object_store::path::Path;
use object_store::{OBJECT_STORE_COALESCE_DEFAULT, ObjectStoreExt, coalesce_ranges};
#[tokio::main]
async fn main() {
let store = InMemory::new();
let path = Path::from("obj");
store.put(&path, "arbitrary data".into()).await.unwrap(); // 14 bytes
// A range starting past the end of the object is an error when requested on its own
let r = store.get_range(&path, 200..300).await;
println!("get_range(200..300) -> {:?}", r.map_err(|e| e.to_string()));
// Body of the default `ObjectStore::get_ranges`
for ranges in [vec![0..5, 14..20], vec![0..5, 200..300]] {
let r = coalesce_ranges(
&ranges,
|r| store.get_range(&path, r),
OBJECT_STORE_COALESCE_DEFAULT,
)
.await;
println!("get_ranges({ranges:?}) -> {:?}", r.map_err(|e| e.to_string()));
}
}
Output:
get_range(200..300) -> Err("Generic InMemory error: Invalid range: Wanted range starting at 200, but object was only 14 bytes long")
get_ranges([0..5, 14..20]) -> Ok([b"arbit", b""])
thread 'main' panicked at .../bytes-1.12.1/src/bytes.rs:374:28:
range start must not be greater than end: 200 <= 14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The loop body is the same as the default get_ranges. I also checked a real store: HttpStore against a small server that follows RFC 9110. That server answers bytes=0-299 on the 14-byte object with 206 and Content-Range: bytes 0-13/14, and answers bytes=200-299 with 416. Against it, get_range(200..300) returns the 416 error, get_ranges(&[0..5, 200..300]) panics with the same message, and get_ranges(&[0..5, 14..20]) returns [b"arbit", b""]. Calling InMemory::get_ranges or LocalFileSystem::get_ranges with the same ranges returns an error. In-bounds ranges such as [0..5, 7..9] work on all of them.
The cause is in coalesce_ranges in src/util.rs:
0..5and200..300are merged into a single fetch of0..300.- A bounded range that runs past the end of the object is truncated. This is the documented
GetRange::Boundedbehaviour, and the HTTP client accepts thebytes 0-13/14response for it. So the merged fetch returns 14 bytes. - Each requested range is then sliced out of that buffer. The end of the slice is clamped to the buffer length, but the start is not checked.
slice(200..14)panics, andslice(14..14)returns an empty buffer.
Expected behavior
get_ranges should return an error for a range that starts at or after the end of the object. That matches get_range for the same range, and InMemory/LocalFileSystem::get_ranges. RFC 9110 section 14.1.2 treats such a range (first position at or past the representation length) as unsatisfiable. The GetRange::Bounded docs say "If the given range is zero-length or starts after the end of the object, an error will be returned". put_get_delete_list in src/integration.rs already expects get_range(200..300) to be a non-fatal error.
Proposed fix: in coalesce_ranges, when the bytes returned for a merged fetch end before a requested range starts, fetch that range on its own and return what the store returns, which is normally its out-of-range error. The public signature stays the same, and the extra request only happens in this error case. Ranges that start inside the object but run past its end are still truncated as today.
Additional context
- object_store main at c216ede (version 0.14.2)
- macOS 26.6 arm64, rustc 1.100.0
- The end clamp was added in apache/arrow-rs#5222. That change made bounded ranges past the end get truncated instead of rejected, but the start of each slice was never checked.
- I have a fix with a regression test: a unit test for
coalesce_ranges, plus aget_rangesassertion input_get_delete_listso the S3/GCS/Azure/HTTP integration runs cover it. I'm happy to open a PR.
This issue was drafted with Claude Code (claude-opus-5-5); the results above are from the runs described.
- Lingua principale
- Rust
- Stelle
- 339
- Fork
- 240
- Merge medio
- 1g 13h
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/arrow-rs-object-store
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/arrow-rs-object-store#914 ·
I maintainer di solito rispondono entro 2 giorni
-
`hyper::Error::is_incomplete_message()` classified as `HttpErrorKind::Request`, retrying non idempotent `PutMode::Create`Forse già presa @hcrosse l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
apache/arrow-rs-object-store#912 ·
I maintainer di solito rispondono entro 2 giorni
-
AWS: list requests are signed without ClientOptions default headers (sent unsigned, S3 403 HeadersNotSigned)Forse già presa @filippoGRiva l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
apache/arrow-rs-object-store#877 ·
I maintainer di solito rispondono entro 2 giorni
-
List requests do not map HTTP status codes to error variants, so 403 and 404 both become `Error::Generic`Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 Mezza giornata Idoneità per principianti 82/100
apache/arrow-rs-object-store#851 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
Errors on 200 Response for entire-object range requestForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/arrow-rs-object-store#806 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di apache/arrow-rs-object-store
Issue simili
-
[Bug] StreamLifecycleConfig clamps post-TTFT stream timeouts to remaining admission budgetForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
lbjlaq/Antigravity-Manager#4063 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
farion1231/cc-switch#9981 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Windows unit tests fail on main: pnpm-registry-overrides fixtures are checked out as CRLF (mixes CRLF and LF line endings)Forse già presa @mikolalysenko l’ha presa oggi. Apertaagent:claimed agent:triaged ci-janitor priority:p1
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
SocketDev/socket-patch#2238 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bot:ai-assisted component:indexer status:untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
midnightntwrk/midnight-indexer#1834 ·
I maintainer di solito rispondono entro 1 giorno