[GH-ISSUE #1871] Storage Class returned in response is empty string when updating object metadata #226

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

Originally created by @DanoBuck on GitHub (Jan 8, 2025).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1871

Hey there,

While testing out the latest released container: version 1.51 - sha256:600fad414f624942a7250d1917c48d6a63cb7212ff85d068cb470a1d274ae6ca, it was observed that when using the google-cloud-storage-2.46.0.jar to make requests to the container we started experiencing errors as seen below when parsing the response back from the container:

java.lang.IllegalArgumentException: Empty enum constants not allowed.
	at com.google.cloud.StringEnumType.valueOf(StringEnumType.java:66)
	at com.google.cloud.storage.StorageClass.valueOf(StorageClass.java:115)
	at com.google.cloud.storage.Utils.ifNonNull(Utils.java:213)
	at com.google.cloud.storage.JsonConversions.blobInfoDecode(JsonConversions.java:326)
	at com.google.cloud.storage.Conversions$SimpleCodec.decode(Conversions.java:149)
	at com.google.cloud.storage.StorageImpl.lambda$update$19(StorageImpl.java:591)
	at com.google.cloud.storage.Retrying.run(Retrying.java:66)
	at com.google.cloud.storage.StorageImpl.run(StorageImpl.java:1608)
	at com.google.cloud.storage.StorageImpl.update(StorageImpl.java:587)
	at com.google.cloud.storage.Blob.update(Blob.java:855)
	. . .

The request used to generate the above error was around updating the metadata of an object.

Upon further inspection, it was observed that the new container was returning the following storage class attribute within the JSON response
"storageClass": "",

I believe this change may be the cause.
Would anyone be able to check this out for me please?
If any more details are needed, please let me know.
Thank you.

Replication steps using curl

  • Run a new Docker container of the fake-gcs-server -> note down the port that the container is listening on:
    docker ps -a # Take 0.0.0.0:62237->4443/tcp
  • Export the port with:
    export GCS_PORT=62237
  • Create a file called bucket.json and add the following contents
    { "name": "test-bucket-env", "location": "US-EAST1" }
  • Create the bucket
    curl -v "localhost:$GCS_PORT/storage/v1/b?project=recreate&projection=full" -H "Content-Type: application/json" -X POST
  • Store an object
    curl -v "localhost:$GCS_PORT/upload/storage/v1/b/test-bucket-env/o?ifGenerationMatch=0&name=dev/repus/collection/entry-id/0/1&uploadType=resumable" -X POST
  • Note down the location header returned from above and run a PUT on it - example below
    curl -v localhost:$GCS_PORT/upload/storage/v1/b/test-bucket-env/o?uploadType=resumable&name=dev%2Frepus%2Fcollection%2Fentry-id%2F0%2F1&upload_id=7a9d76ad6c0219f6f8dcadbca889f9d4
  • Retrieve the object
    curl -v "localhost:$GCS_PORT/storage/v1/b/test-bucket-env/o/dev%2Frepus%2Fcollection%2Fentry-id%2F0%2F1?projection=full"
  • Note the generation in the response returned - example below
    1736335690830320
  • Create a file called metadata.json and add the following
    { "metadata": { "tag-1": "true", "tag-2": "2024-01-29 11:53:04", "tag-3": "2024-01-17 11:53:12" } }
  • Update the metadata on the object - replace the ifGenerationMatch=1736335821147726 with the value noted down from above
    curl -v "localhost:62237/storage/v1/b/test-bucket-env/o/dev%2Frepus%2Fcollection%2Fentry-id%2F0%2F1?ifGenerationMatch=1736335821147726&projection=full" -X POST --data-binary @metadata.json
  • Note the response appears similar to the below where storageClass is set to empty string:
{
    "bucket": "test-bucket-env",
    "name": "dev/repus/collection/entry-id/0/1",
    "size": "0",
    "storageClass": "",
    "contentType": "application/octet-stream",
    "contentEncoding": "",
    "contentDisposition": "",
    "contentLanguage": "",
    "crc32c": "AAAAAA==",
    "md5Hash": "1B2M2Y8AsgTpgAmY7PhCfg==",
    "etag": "1B2M2Y8AsgTpgAmY7PhCfg==",
    "acl": [
        {
            "entity": "projectOwner-test-project",
            "entityId": "",
            "role": "OWNER",
            "domain": "",
            "email": "",
            "projectTeam": null
        }
    ],
    "created": "2025-01-08T11:30:21.147715Z",
    "updated": "2025-01-08T11:30:21.147724Z",
    "deleted": "0001-01-01T00:00:00Z",
    "customTime": "0001-01-01T00:00:00Z",
    "generation": "1736337160268699",
    "metadata": {
        "tag-1": "true",
        "tag-2": "2024-01-29 11:53:04",
        "tag-3": "2024-01-17 11:53:12"
    }
}

Diff between version 1.50 and 1.51

response_diff

Originally created by @DanoBuck on GitHub (Jan 8, 2025). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1871 Hey there, While testing out the latest released container: [version 1.51 - sha256:600fad414f624942a7250d1917c48d6a63cb7212ff85d068cb470a1d274ae6ca](https://hub.docker.com/layers/fsouza/fake-gcs-server/1.51.0/images/sha256-68535c9148d767d1d522dd923a8f9438b11ac9018cc6004a1a8c20df2dc67abf), it was observed that when using the google-cloud-storage-2.46.0.jar to make requests to the container we started experiencing errors as seen below when parsing the response back from the container: ``` java.lang.IllegalArgumentException: Empty enum constants not allowed. at com.google.cloud.StringEnumType.valueOf(StringEnumType.java:66) at com.google.cloud.storage.StorageClass.valueOf(StorageClass.java:115) at com.google.cloud.storage.Utils.ifNonNull(Utils.java:213) at com.google.cloud.storage.JsonConversions.blobInfoDecode(JsonConversions.java:326) at com.google.cloud.storage.Conversions$SimpleCodec.decode(Conversions.java:149) at com.google.cloud.storage.StorageImpl.lambda$update$19(StorageImpl.java:591) at com.google.cloud.storage.Retrying.run(Retrying.java:66) at com.google.cloud.storage.StorageImpl.run(StorageImpl.java:1608) at com.google.cloud.storage.StorageImpl.update(StorageImpl.java:587) at com.google.cloud.storage.Blob.update(Blob.java:855) . . . ``` The request used to generate the above error was around updating the metadata of an object. Upon further inspection, it was observed that the new container was returning the following storage class attribute within the JSON response ` "storageClass": "", ` I believe [this change](https://github.com/fsouza/fake-gcs-server/pull/1826/files) may be the cause. Would anyone be able to check this out for me please? If any more details are needed, please let me know. Thank you. ### Replication steps using curl - Run a new Docker container of the fake-gcs-server -> note down the port that the container is listening on: `docker ps -a # Take 0.0.0.0:62237->4443/tcp` - Export the port with: `export GCS_PORT=62237` - Create a file called bucket.json and add the following contents ` { "name": "test-bucket-env", "location": "US-EAST1" } ` - Create the bucket `curl -v "localhost:$GCS_PORT/storage/v1/b?project=recreate&projection=full" -H "Content-Type: application/json" -X POST` - Store an object `curl -v "localhost:$GCS_PORT/upload/storage/v1/b/test-bucket-env/o?ifGenerationMatch=0&name=dev/repus/collection/entry-id/0/1&uploadType=resumable" -X POST` - Note down the location header returned from above and run a PUT on it - example below `curl -v localhost:$GCS_PORT/upload/storage/v1/b/test-bucket-env/o?uploadType=resumable&name=dev%2Frepus%2Fcollection%2Fentry-id%2F0%2F1&upload_id=7a9d76ad6c0219f6f8dcadbca889f9d4` - Retrieve the object `curl -v "localhost:$GCS_PORT/storage/v1/b/test-bucket-env/o/dev%2Frepus%2Fcollection%2Fentry-id%2F0%2F1?projection=full"` - Note the generation in the response returned - example below `1736335690830320` - Create a file called metadata.json and add the following ` { "metadata": { "tag-1": "true", "tag-2": "2024-01-29 11:53:04", "tag-3": "2024-01-17 11:53:12" } } ` - Update the metadata on the object - replace the ifGenerationMatch=1736335821147726 with the value noted down from above `curl -v "localhost:62237/storage/v1/b/test-bucket-env/o/dev%2Frepus%2Fcollection%2Fentry-id%2F0%2F1?ifGenerationMatch=1736335821147726&projection=full" -X POST --data-binary @metadata.json` - Note the response appears similar to the below where storageClass is set to empty string: ``` { "bucket": "test-bucket-env", "name": "dev/repus/collection/entry-id/0/1", "size": "0", "storageClass": "", "contentType": "application/octet-stream", "contentEncoding": "", "contentDisposition": "", "contentLanguage": "", "crc32c": "AAAAAA==", "md5Hash": "1B2M2Y8AsgTpgAmY7PhCfg==", "etag": "1B2M2Y8AsgTpgAmY7PhCfg==", "acl": [ { "entity": "projectOwner-test-project", "entityId": "", "role": "OWNER", "domain": "", "email": "", "projectTeam": null } ], "created": "2025-01-08T11:30:21.147715Z", "updated": "2025-01-08T11:30:21.147724Z", "deleted": "0001-01-01T00:00:00Z", "customTime": "0001-01-01T00:00:00Z", "generation": "1736337160268699", "metadata": { "tag-1": "true", "tag-2": "2024-01-29 11:53:04", "tag-3": "2024-01-17 11:53:12" } } ``` ### Diff between version 1.50 and 1.51 ![response_diff](https://github.com/user-attachments/assets/635c1d45-5550-43f1-a794-9ca523280874)
kerem 2026-03-03 12:09:17 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@olegbonar commented on GitHub (Jan 8, 2025):

We are facing the same problem.

<!-- gh-comment-id:2577759599 --> @olegbonar commented on GitHub (Jan 8, 2025): We are facing the same problem.
Author
Owner

@fsouza commented on GitHub (Jan 10, 2025):

Thanks for reporting! This should be fixed in 1.52.1 now.

<!-- gh-comment-id:2581658792 --> @fsouza commented on GitHub (Jan 10, 2025): Thanks for reporting! This should be fixed in 1.52.1 now.
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#226
No description provided.