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

   # Which issue does this PR close?
   
   Closes #8952.
   
   # Rationale for this change
   
   `GcsReader` copies the `ETag` response header into the read metadata 
verbatim, while `stat` and `list` take the JSON API `etag` field. Real GCS 
sends both unquoted, so they agree there. fake-gcs-server quotes the media 
download header, so the same object reports `"abc=="` from read and `abc==` 
from stat.
   
   `CacheLayer` digests the etag into the object identity, so the mismatch 
makes a `stat` between two cached reads look like a changed object and the next 
read goes back to the origin. The unquoted form is also the only one GCS 
honours in JSON API preconditions: a quoted `If-Match` gets 412 and a quoted 
`If-None-Match` gets 200 instead of 304.
   
   # What changes are included in this PR?
   
   - `GcsReader` strips one pair of surrounding quotes from the `ETag` header, 
so read, stat and list report the same JSON API form. Unquoted values (real 
GCS) are unchanged.
   - A unit test with a mocked transport covers both header forms.
   
   Checked with an OpenDAL-only harness (`Gcs` + `CacheLayer` over `Memory`, 
with a request-counting `HttpTransport`):
   
   | Target | Branch | stat etag == read etag | Origin GETs on a cached re-read 
after `stat` |
   | --- | --- | --- | --- |
   | Real GCS, public object (`gcp-public-data-landsat`) | main | yes | 0 |
   | Real GCS, public object | this PR | yes | 0 |
   | fake-gcs-server 1.52.2 | main | no | 1 |
   | fake-gcs-server 1.52.2 | this PR | yes | 0 |
   
   On real GCS, both etags still round-trip through `stat_with().if_match`, 
`stat_with().if_none_match` and `read_with().if_none_match` on this branch. The 
GCS behavior suite against fake-gcs-server 1.56.1 fails the same 52 tests on 
main and on this branch (the emulator ignores preconditions, generations and 
some upload types), with no new failures.
   
   # Are there any user-facing changes?
   
   Only against servers that quote the media `ETag` header: `Metadata::etag()` 
from a read now matches stat and list. Nothing changes against GCS itself.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: Jcode
   - Model: Claude
   - Effort: default
   - Role: Probed etag forms and precondition handling on real GCS and 
fake-gcs-server with curl, wrote the fix and unit test, and ran the harness and 
the behavior suite above. I reviewed the change and the results.
   


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