[GH-ISSUE #206] "prefixes" key is always in the response of Object:list even if it's empty. #2185

Closed
opened 2026-03-15 17:57:00 +03:00 by kerem · 2 comments
Owner

Originally created by @reppets on GitHub (Mar 25, 2020).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/206

version 1.18 (dockerhub image)

The responses of /storage/v1/b/bucket/o (Object: list) on the fake server have always "prefixes" key even when it's empty, while the genuine server's responses are without that key.
If "prefixes" is empty, fake-gcs-server returns "prefixes" key with an empty array.

For example (using Google's public bucket gs://gcp-public-data-landsat/ and same directory structure for fake-gcs-server)

The fake-gcs-server response is

# wget --no-proxy --no-check-certificate -q -O - "https://localhost:4443/storage/v1/b/gcp-public-data-landsat/o?prefix=LC08%2f01%2f0
01%2f002%2fLC08_L1GT_001002_20160817_20170322_01_T2%2f" |  jq
{
  "kind": "storage#objects",
  "items": [
    // 13 file objects
  ],
  "prefixes": []
}

And here are examples of the GCS response below

1. without delimiter option

https://storage.googleapis.com/storage/v1/b/gcp-public-data-landsat/o?prefix=LC08%2f01%2f001%2f002%2fLC08_L1GT_001002_20160817_20170322_01_T2%2f

returns

{
  "kind": "storage#objects",
  "items": [
    // 13 file objects
  ]
}

"prefixes" key is not present.

2. with delimiter option matches nothing

https://storage.googleapis.com/storage/v1/b/gcp-public-data-landsat/o?delimiter=nomatch&prefix=LC08%2f01%2f001%2f002%2fLC08_L1GT_001002_20160817_20170322_01_T2%2f

returns the same response as 1.

3. with delimeter option matches some files

https://storage.googleapis.com/storage/v1/b/gcp-public-data-landsat/o?delimiter=.TIF&prefix=LC08%2f01%2f001%2f002%2fLC08_L1GT_001002_20160817_20170322_01_T2%2f

returns

{
  "kind": "storage#objects",
  "prefixes": [
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B1.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B10.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B11.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B2.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B3.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B4.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B5.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B6.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B7.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B8.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B9.TIF",
    "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_BQA.TIF"
  ],
  "items": [
    // 2 file objects
  ]
}

has "prefix" key with values.

Originally created by @reppets on GitHub (Mar 25, 2020). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/206 version 1.18 (dockerhub image) The responses of /storage/v1/b/bucket/o (Object: list) on the fake server have always "prefixes" key even when it's empty, while the genuine server's responses are without that key. If "prefixes" is empty, fake-gcs-server returns "prefixes" key with an empty array. For example (using Google's public bucket gs://gcp-public-data-landsat/ and same directory structure for fake-gcs-server) The fake-gcs-server response is ``` # wget --no-proxy --no-check-certificate -q -O - "https://localhost:4443/storage/v1/b/gcp-public-data-landsat/o?prefix=LC08%2f01%2f0 01%2f002%2fLC08_L1GT_001002_20160817_20170322_01_T2%2f" | jq { "kind": "storage#objects", "items": [ // 13 file objects ], "prefixes": [] } ``` And here are examples of the GCS response below #### 1. without delimiter option https://storage.googleapis.com/storage/v1/b/gcp-public-data-landsat/o?prefix=LC08%2f01%2f001%2f002%2fLC08_L1GT_001002_20160817_20170322_01_T2%2f returns ``` { "kind": "storage#objects", "items": [ // 13 file objects ] } ``` "prefixes" key is not present. #### 2. with delimiter option matches nothing https://storage.googleapis.com/storage/v1/b/gcp-public-data-landsat/o?delimiter=nomatch&prefix=LC08%2f01%2f001%2f002%2fLC08_L1GT_001002_20160817_20170322_01_T2%2f returns the same response as 1. #### 3. with delimeter option matches some files https://storage.googleapis.com/storage/v1/b/gcp-public-data-landsat/o?delimiter=.TIF&prefix=LC08%2f01%2f001%2f002%2fLC08_L1GT_001002_20160817_20170322_01_T2%2f returns ``` { "kind": "storage#objects", "prefixes": [ "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B1.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B10.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B11.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B2.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B3.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B4.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B5.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B6.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B7.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B8.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_B9.TIF", "LC08/01/001/002/LC08_L1GT_001002_20160817_20170322_01_T2/LC08_L1GT_001002_20160817_20170322_01_T2_BQA.TIF" ], "items": [ // 2 file objects ] } ``` has "prefix" key with values.
kerem closed this issue 2026-03-15 17:57:05 +03:00
Author
Owner

@fsouza commented on GitHub (Mar 25, 2020):

Thanks for reporting! Just pushed a fix and tagged 1.18.1.

<!-- gh-comment-id:603988419 --> @fsouza commented on GitHub (Mar 25, 2020): Thanks for reporting! Just pushed a fix and tagged 1.18.1.
Author
Owner

@reppets commented on GitHub (Mar 25, 2020):

Thank you for the fix and such a quick response!

<!-- gh-comment-id:604148636 --> @reppets commented on GitHub (Mar 25, 2020): Thank you for the fix and such a quick response!
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#2185
No description provided.