[GH-ISSUE #349] Incorrect handling of paths which start with a / #70

Open
opened 2026-03-03 12:07:59 +03:00 by kerem · 0 comments
Owner

Originally created by @jeantil on GitHub (Oct 21, 2020).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/349

I have updated the sample in #345 to add the ability to log http requests.

According to the documentation object names must adhere to some rules but may start with a /
While I don't expect this project to fully follow the naming rules in the documentation, incorrect handling of paths which start with a / is problematic because such paths are used as exemples in the documentation (such as /europe/france/paris.jpg) which can be a bad experience for begginers.

below are HTTP traces for both cases

  • writing europe/france/paris.jpg ✔️
POST /upload/storage/v1/b/bucket_1603295698243689564/o?uploadType=multipart&name=europe%2Ffrance%2Fparis.jpg
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
content-type: multipart/related; boundary=1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03
accept: */*
accept-encoding: gzip,deflate
host: 127.0.0.1:4443
--1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03
Content-Type: application/json

{"contentType":"image/jpeg"}
--1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03
Content-Type: image/jpeg

fake-gcs-server is awesome
--1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03--

HTTP/1.1 200
date: Wed, 21 Oct 2020 15:54:58 GMT
content-length: 357
content-type: text/plain; charset=utf-8
{"name":"europe/france/paris.jpg","contentType":"image/jpeg","contentEncoding":"","crc32c":"qHNz6Q==","md5Hash":"nBHYLqMw7b5xFMag+TA1/Q==","acl":[{"Entity":"projectOwner","EntityID":"","Role":"OWNER","Domain":"","Email":"","ProjectTeam":null}],"created":"2020-10-21T15:54:58.30484Z","updated":"2020-10-21T15:54:58.304845Z","deleted":"0001-01-01T00:00:00Z"}
  • reading europe/france/paris.jpg ✔️
GET /storage/v1/b/bucket_1603295698243689564/o/europe%2Ffrance%2Fparis.jpg?alt=media
accept-encoding: gzip
cache-control: no-store
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
accept: */*
connection: close
host: 127.0.0.1:4443

HTTP/1.1 200
accept-ranges: bytes
content-length: 26
content-type: image/jpeg
last-modified: Wed, 21 Oct 2020 15:54:58 GMT
x-goog-generation: 0
date: Wed, 21 Oct 2020 15:54:58 GMT
connection: close
fake-gcs-server is awesome
  • writing /europe/france/paris.jpg ✔️
OST /upload/storage/v1/b/bucket_1603295793089694316/o?uploadType=multipart&name=%2Feurope%2Ffrance%2Fparis.jpg
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
content-type: multipart/related; boundary=8fcb57f0-b60e-43cd-b385-ec62eef57762
accept: */*
accept-encoding: gzip,deflate
host: 127.0.0.1:4443
--8fcb57f0-b60e-43cd-b385-ec62eef57762
Content-Type: application/json

{"contentType":"image/jpeg"}
--8fcb57f0-b60e-43cd-b385-ec62eef57762
Content-Type: image/jpeg

fake-gcs-server is awesome
--8fcb57f0-b60e-43cd-b385-ec62eef57762--

HTTP/1.1 200
date: Wed, 21 Oct 2020 15:56:33 GMT
content-length: 359
content-type: text/plain; charset=utf-8
{"name":"/europe/france/paris.jpg","contentType":"image/jpeg","contentEncoding":"","crc32c":"qHNz6Q==","md5Hash":"nBHYLqMw7b5xFMag+TA1/Q==","acl":[{"Entity":"projectOwner","EntityID":"","Role":"OWNER","Domain":"","Email":"","ProjectTeam":null}],"created":"2020-10-21T15:56:33.161242Z","updated":"2020-10-21T15:56:33.161257Z","deleted":"0001-01-01T00:00:00Z"}

  • reading /europe/france/paris.jpg
GET /storage/v1/b/bucket_1603295793089694316/o/%2Feurope%2Ffrance%2Fparis.jpg?alt=media
accept-encoding: gzip
cache-control: no-store
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
accept: */*
connection: close
host: 127.0.0.1:4443

HTTP/1.1 301
location: /storage/v1/b/bucket_1603295793089694316/o/europe/france/paris.jpg?alt=media
date: Wed, 21 Oct 2020 15:56:33 GMT
content-length: 0
connection: close

GET /storage/v1/b/bucket_1603295793089694316/o/europe/france/paris.jpg?alt=media
accept-encoding: gzip
cache-control: no-store
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
accept: */*
connection: close
host: 127.0.0.1:4443

HTTP/1.1 404
content-type: text/plain; charset=utf-8
x-content-type-options: nosniff
date: Wed, 21 Oct 2020 15:56:33 GMT
content-length: 10
connection: close
Not Found
Originally created by @jeantil on GitHub (Oct 21, 2020). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/349 I have updated the sample in #345 to add the ability to log http requests. According to the [documentation](https://cloud.google.com/storage/docs/naming-objects) object names must adhere to some rules but may start with a / While I don't expect this project to fully follow the naming rules in the documentation, incorrect handling of paths which start with a / is problematic because such paths are used as exemples in the documentation (such as `/europe/france/paris.jpg`) which can be a bad experience for begginers. below are HTTP traces for both cases * writing `europe/france/paris.jpg` :heavy_check_mark: ``` POST /upload/storage/v1/b/bucket_1603295698243689564/o?uploadType=multipart&name=europe%2Ffrance%2Fparis.jpg user-agent: gcloud-node-storage/5.3.0 x-goog-api-client: gl-node/12.18.3 gccl/5.3.0 authorization: [...redacted...] content-type: multipart/related; boundary=1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03 accept: */* accept-encoding: gzip,deflate host: 127.0.0.1:4443 --1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03 Content-Type: application/json {"contentType":"image/jpeg"} --1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03 Content-Type: image/jpeg fake-gcs-server is awesome --1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03-- HTTP/1.1 200 date: Wed, 21 Oct 2020 15:54:58 GMT content-length: 357 content-type: text/plain; charset=utf-8 {"name":"europe/france/paris.jpg","contentType":"image/jpeg","contentEncoding":"","crc32c":"qHNz6Q==","md5Hash":"nBHYLqMw7b5xFMag+TA1/Q==","acl":[{"Entity":"projectOwner","EntityID":"","Role":"OWNER","Domain":"","Email":"","ProjectTeam":null}],"created":"2020-10-21T15:54:58.30484Z","updated":"2020-10-21T15:54:58.304845Z","deleted":"0001-01-01T00:00:00Z"} ``` * reading `europe/france/paris.jpg` :heavy_check_mark: ``` GET /storage/v1/b/bucket_1603295698243689564/o/europe%2Ffrance%2Fparis.jpg?alt=media accept-encoding: gzip cache-control: no-store user-agent: gcloud-node-storage/5.3.0 x-goog-api-client: gl-node/12.18.3 gccl/5.3.0 authorization: [...redacted...] accept: */* connection: close host: 127.0.0.1:4443 HTTP/1.1 200 accept-ranges: bytes content-length: 26 content-type: image/jpeg last-modified: Wed, 21 Oct 2020 15:54:58 GMT x-goog-generation: 0 date: Wed, 21 Oct 2020 15:54:58 GMT connection: close fake-gcs-server is awesome ``` * writing `/europe/france/paris.jpg` :heavy_check_mark: ``` OST /upload/storage/v1/b/bucket_1603295793089694316/o?uploadType=multipart&name=%2Feurope%2Ffrance%2Fparis.jpg user-agent: gcloud-node-storage/5.3.0 x-goog-api-client: gl-node/12.18.3 gccl/5.3.0 authorization: [...redacted...] content-type: multipart/related; boundary=8fcb57f0-b60e-43cd-b385-ec62eef57762 accept: */* accept-encoding: gzip,deflate host: 127.0.0.1:4443 --8fcb57f0-b60e-43cd-b385-ec62eef57762 Content-Type: application/json {"contentType":"image/jpeg"} --8fcb57f0-b60e-43cd-b385-ec62eef57762 Content-Type: image/jpeg fake-gcs-server is awesome --8fcb57f0-b60e-43cd-b385-ec62eef57762-- HTTP/1.1 200 date: Wed, 21 Oct 2020 15:56:33 GMT content-length: 359 content-type: text/plain; charset=utf-8 {"name":"/europe/france/paris.jpg","contentType":"image/jpeg","contentEncoding":"","crc32c":"qHNz6Q==","md5Hash":"nBHYLqMw7b5xFMag+TA1/Q==","acl":[{"Entity":"projectOwner","EntityID":"","Role":"OWNER","Domain":"","Email":"","ProjectTeam":null}],"created":"2020-10-21T15:56:33.161242Z","updated":"2020-10-21T15:56:33.161257Z","deleted":"0001-01-01T00:00:00Z"} ``` * reading `/europe/france/paris.jpg` ❌ ``` GET /storage/v1/b/bucket_1603295793089694316/o/%2Feurope%2Ffrance%2Fparis.jpg?alt=media accept-encoding: gzip cache-control: no-store user-agent: gcloud-node-storage/5.3.0 x-goog-api-client: gl-node/12.18.3 gccl/5.3.0 authorization: [...redacted...] accept: */* connection: close host: 127.0.0.1:4443 HTTP/1.1 301 location: /storage/v1/b/bucket_1603295793089694316/o/europe/france/paris.jpg?alt=media date: Wed, 21 Oct 2020 15:56:33 GMT content-length: 0 connection: close GET /storage/v1/b/bucket_1603295793089694316/o/europe/france/paris.jpg?alt=media accept-encoding: gzip cache-control: no-store user-agent: gcloud-node-storage/5.3.0 x-goog-api-client: gl-node/12.18.3 gccl/5.3.0 authorization: [...redacted...] accept: */* connection: close host: 127.0.0.1:4443 HTTP/1.1 404 content-type: text/plain; charset=utf-8 x-content-type-options: nosniff date: Wed, 21 Oct 2020 15:56:33 GMT content-length: 10 connection: close Not Found ```
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#70
No description provided.