ItsM0rty opened a new issue, #881:
URL: https://github.com/apache/arrow-rs-object-store/issues/881

   **Describe the bug**
   
   `GetOptions::check_preconditions` uses exact string comparison for both 
`if_match` and `if_none_match`. This does not account for weak entity tags:
   
   - Metadata ETag `"1"` with `if_none_match = W/"1"` succeeds instead of 
returning `Error::NotModified`.
   - Metadata ETag `W/"1"` with `if_none_match = "1"` also succeeds.
   - Metadata ETag `W/"1"` with `if_match = W/"1"` succeeds instead of 
returning `Error::Precondition`.
   
   The first case also reproduces through a real `InMemory` store, not just a 
constructed metadata value.
   
   **To Reproduce**
   
   Run this test against main (`279572ea60f3a7a6e5237e066a6f4a35eee611e0`, 
object_store 0.14.2):
   
   ```rust
   #[tokio::test]
   async fn weak_if_none_match() {
       use bytes::Bytes;
       use object_store::{Error, GetOptions, ObjectStore, ObjectStoreExt, 
memory::InMemory, path::Path};
   
       let store = InMemory::new();
       let path = Path::from("cached-object");
       let put = store.put(&path, 
Bytes::from_static(b"data").into()).await.unwrap();
       let options = GetOptions::new()
           .with_if_none_match(Some(format!("W/{}", put.e_tag.unwrap())));
   
       assert!(matches!(store.get_opts(&path, options).await, 
Err(Error::NotModified { .. })));
   }
   ```
   
   The assertion fails because `get_opts` returns `Ok(GetResult)`.
   
   **Expected behavior**
   
   Use weak comparison for `If-None-Match` and strong comparison for 
`If-Match`, as required by [RFC 9110 section 
13.1.2](https://www.rfc-editor.org/rfc/rfc9110.html#section-13.1.2) and 
[section 13.1.1](https://www.rfc-editor.org/rfc/rfc9110.html#section-13.1.1). 
The comparison table in [section 
8.8.3.2](https://www.rfc-editor.org/rfc/rfc9110.html#section-8.8.3.2) includes 
these weak/strong combinations.
   
   **Additional context**
   
   I have a focused fix and three regression tests ready. They fail on 
unchanged production code and pass with the fix. Tests cover weak/strong 
combinations, tag lists, whitespace, nonmatches, wildcard `If-Match` and an 
actual in-memory conditional read.
   
   The shared helper is used by `InMemory` and `LocalFileSystem`. This report 
does not establish a bug in cloud providers that evaluate forwarded conditional 
headers themselves. It is separate from #769/#770, which changed how returned 
ETags are quoted.
   
   
   Proposed fix and executable tests: 
https://github.com/ItsM0rty/arrow-rs-object-store/commit/81d25d0d5b8ac858d8a561bd0dfbfaf1441ebafa
   


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