Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage Class returned in response is empty string when updating object metadata #1871

Closed
DanoBuck opened this issue Jan 8, 2025 · 2 comments · Fixed by #1878
Closed

Storage Class returned in response is empty string when updating object metadata #1871

DanoBuck opened this issue Jan 8, 2025 · 2 comments · Fixed by #1878
Labels

Comments

@DanoBuck
Copy link

DanoBuck commented Jan 8, 2025

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

@olegbonar
Copy link

We are facing the same problem.

@fsouza fsouza added the bug label Jan 8, 2025
fsouza added a commit that referenced this issue Jan 10, 2025
@fsouza fsouza closed this as completed in ada9886 Jan 10, 2025
@fsouza
Copy link
Owner

fsouza commented Jan 10, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants