[GH-ISSUE #1327] etag value has extra backslashes when uploading object #188

Closed
opened 2026-03-03 12:09:02 +03:00 by kerem · 2 comments
Owner

Originally created by @szgupta on GitHub (Sep 13, 2023).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1327

When uploading an object against a fake-gcs-server, I'm noticing that the etag value has escaped backslashes before and after the actual md5 hash. Looks to be due to poor escaping. A GCS client library that I'm using fails to parse the etag attribute because of this. I wasn't able to repro when uploading against GCS itself.

Raw json output when uploading against fake-gcs-server:

"... , \"etag\": \"\\\"1B2M2Y8AsgTpgAmY7PhCfg==\\\"\", ..."

Raw json output when uploading against GCS itself:

"... , \"etag\": \"TKb9iteyqIEDEEE=\", ..."
Originally created by @szgupta on GitHub (Sep 13, 2023). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1327 When uploading an object against a `fake-gcs-server`, I'm noticing that the `etag` value has escaped backslashes before and after the actual md5 hash. Looks to be due to poor escaping. A GCS client library that I'm using fails to parse the `etag` attribute because of this. I wasn't able to repro when uploading against GCS itself. Raw json output when uploading against `fake-gcs-server`: ``` "... , \"etag\": \"\\\"1B2M2Y8AsgTpgAmY7PhCfg==\\\"\", ..." ``` Raw json output when uploading against GCS itself: ``` "... , \"etag\": \"TKb9iteyqIEDEEE=\", ..." ```
kerem closed this issue 2026-03-03 12:09:02 +03:00
Author
Owner

@fsouza commented on GitHub (Sep 22, 2023):

@szgupta can you provide more details a bit? Like which backend are you using (if you can share the command you used to start the server, that would be perfect) and a small reproducer with the client you're using. I suspect the issue is not specific to any clients or the backend, but having more information helps me debug the issue.

Also, is that JSON snippet from the response for get object?

<!-- gh-comment-id:1730737400 --> @fsouza commented on GitHub (Sep 22, 2023): @szgupta can you provide more details a bit? Like which backend are you using (if you can share the command you used to start the server, that would be perfect) and a small reproducer with the client you're using. I suspect the issue is not specific to any clients or the backend, but having more information helps me debug the issue. Also, is that JSON snippet from the response for get object?
Author
Owner

@seemeroland commented on GitHub (Nov 10, 2023):

Here is a minimal reproduction:

Start with some test data.

mkdir data
cd data
mkdir test-bucket
cd test-bucket
echo "text" > text.txt

Go back to base directory and start fake-gcs-server through docker

docker run -d --name fake-gcs-server -p 4443:4443 -v ./data:/data fsouza/fake-gcs-server -scheme http

Get objects with prefix

curl http://localhost:4443/storage/v1/b/test-bucket/o?prefix=te

Output:

{"kind":"storage#objects","items":[{"kind":"storage#object","name":"text.txt","id":"test-bucket/text.txt","bucket":"test-bucket","size":"5","contentType":"text/plain; charset=utf-8","crc32c":"KOsDaQ==","acl":[{"bucket":"test-bucket","entity":"projectOwner-test-project","object":"text.txt","projectTeam":{},"role":"OWNER"}],"md5Hash":"4cuww4ea+DRyRvEsVZqGtQ==","etag":"\"4cuww4ea+DRyRvEsVZqGtQ==\"","timeCreated":"2023-11-10T00:35:12.25986Z","updated":"2023-11-10T00:35:12.25989Z","generation":"1699576512259897"}]}

etag is "etag":"\"4cuww4ea+DRyRvEsVZqGtQ==\""

<!-- gh-comment-id:1804896097 --> @seemeroland commented on GitHub (Nov 10, 2023): Here is a minimal reproduction: Start with some test data. ``` mkdir data cd data mkdir test-bucket cd test-bucket echo "text" > text.txt ``` Go back to base directory and start fake-gcs-server through docker ``` docker run -d --name fake-gcs-server -p 4443:4443 -v ./data:/data fsouza/fake-gcs-server -scheme http ``` Get objects with prefix ``` curl http://localhost:4443/storage/v1/b/test-bucket/o?prefix=te ``` Output: ``` {"kind":"storage#objects","items":[{"kind":"storage#object","name":"text.txt","id":"test-bucket/text.txt","bucket":"test-bucket","size":"5","contentType":"text/plain; charset=utf-8","crc32c":"KOsDaQ==","acl":[{"bucket":"test-bucket","entity":"projectOwner-test-project","object":"text.txt","projectTeam":{},"role":"OWNER"}],"md5Hash":"4cuww4ea+DRyRvEsVZqGtQ==","etag":"\"4cuww4ea+DRyRvEsVZqGtQ==\"","timeCreated":"2023-11-10T00:35:12.25986Z","updated":"2023-11-10T00:35:12.25989Z","generation":"1699576512259897"}]} ``` etag is `"etag":"\"4cuww4ea+DRyRvEsVZqGtQ==\""`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#188
No description provided.