[GH-ISSUE #701] Missing generation field causes issues with official Google PHP Client #119

Closed
opened 2026-03-03 12:08:27 +03:00 by kerem · 17 comments
Owner

Originally created by @veteran29 on GitHub (Mar 2, 2022).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/701

When a file is uploaded to the bucket with the PHP client provided by Google it expects generation field in the response, see:
https://github.com/googleapis/google-cloud-php-storage/blob/main/src/Bucket.php#L301

Could you please change it so this field is present with a null value instead of omitting it from serialization when it's not set?

Originally created by @veteran29 on GitHub (Mar 2, 2022). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/701 When a file is uploaded to the bucket with the PHP client provided by Google it expects `generation` field in the response, see: https://github.com/googleapis/google-cloud-php-storage/blob/main/src/Bucket.php#L301 Could you please change it so this field is present with a `null` value instead of omitting it from serialization when it's not set?
kerem 2026-03-03 12:08:27 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@fsouza commented on GitHub (Mar 2, 2022):

Oh interesting. Yeah that should be an easy change. Do you want to send a PR or do you want me to do it? I should be able to do it later today.

<!-- gh-comment-id:1057222943 --> @fsouza commented on GitHub (Mar 2, 2022): Oh interesting. Yeah that should be an easy change. Do you want to send a PR or do you want me to do it? I should be able to do it later today.
Author
Owner

@veteran29 commented on GitHub (Mar 3, 2022):

I would be grateful if you could please do this. I do not code in Go (It looks pretty simple to get into though!) and just wanted to use this project with Google PHP SDK for Cloud Storage.

<!-- gh-comment-id:1057670564 --> @veteran29 commented on GitHub (Mar 3, 2022): I would be grateful if you could please do this. I do not code in Go (It looks pretty simple to get into though!) and just wanted to use this project with Google PHP SDK for Cloud Storage.
Author
Owner

@fsouza commented on GitHub (Mar 3, 2022):

I would be grateful if you could please do this. I do not code in Go (It looks pretty simple to get into though!) and just wanted to use this project with Google PHP SDK for Cloud Storage.

Sorry I didn't get to it today but I will make the change tomorrow.

<!-- gh-comment-id:1057674539 --> @fsouza commented on GitHub (Mar 3, 2022): > I would be grateful if you could please do this. I do not code in Go (It looks pretty simple to get into though!) and just wanted to use this project with Google PHP SDK for Cloud Storage. Sorry I didn't get to it today but I will make the change tomorrow.
Author
Owner

@fsouza commented on GitHub (Mar 3, 2022):

Hmm I'm curious whether the GCS API returns "", "0" or null. Do you have an example from a real request? If not, I can get one later.

<!-- gh-comment-id:1058252169 --> @fsouza commented on GitHub (Mar 3, 2022): Hmm I'm curious whether the GCS API returns `""`, `"0"` or `null`. Do you have an example from a real request? If not, I can get one later.
Author
Owner

@veteran29 commented on GitHub (Mar 3, 2022):

I've done a quick test upload via their web interface and got generation: "1646335421345034" for empty txt file.
It looks like it's Epoch in microseconds as it matches upload time.

I've assumed it might be null by default as their PHP class for the StorageObject has null as its default value, but it might not be right.

<!-- gh-comment-id:1058407647 --> @veteran29 commented on GitHub (Mar 3, 2022): I've done a quick test upload via their web interface and got `generation: "1646335421345034"` for empty txt file. It looks like it's Epoch in microseconds as it matches upload time. I've assumed it might be null by default as their PHP class for the [StorageObject](https://github.com/googleapis/google-cloud-php-storage/blob/1382afef595c2ced1c5e39ead91d903e8ebc8e22/src/StorageObject.php#L94) has null as its default value, but it might not be right.
Author
Owner

@fsouza commented on GitHub (Apr 5, 2022):

@veteran29 sorry completely missed this, do you know what the API returns if generation is disabled in the bucket? I'll give it a try on the weekend.

<!-- gh-comment-id:1089286037 --> @fsouza commented on GitHub (Apr 5, 2022): @veteran29 sorry completely missed this, do you know what the API returns if generation is disabled in the bucket? I'll give it a try on the weekend.
Author
Owner

@seniorcatDDL commented on GitHub (Jun 2, 2022):

Hi, any updates here? I have the same problem with php client

<!-- gh-comment-id:1144550934 --> @seniorcatDDL commented on GitHub (Jun 2, 2022): Hi, any updates here? I have the same problem with php client
Author
Owner

@fsouza commented on GitHub (Jun 2, 2022):

Hi, any updates here? I have the same problem with php client

Sorry, still didn't get a chance to inspect what the value should be when the bucket has versioning disabled. Do you know what the API returns if generation is disabled in the bucket?

I know I can create a bucket and check, but wondering if this is something y'all can help with.

<!-- gh-comment-id:1144772638 --> @fsouza commented on GitHub (Jun 2, 2022): > Hi, any updates here? I have the same problem with php client Sorry, still didn't get a chance to inspect what the value should be when the bucket has versioning disabled. Do you know what the API returns if generation is disabled in the bucket? I know I can create a bucket and check, but wondering if this is something y'all can help with.
Author
Owner

@mmetayer commented on GitHub (Jun 2, 2022):

As far as I understand the docs (https://cloud.google.com/storage/docs/object-versioning and https://cloud.google.com/storage/docs/metadata#generation-number) there is always a generation number returned, whether the versioning is enabled or not.

<!-- gh-comment-id:1144806216 --> @mmetayer commented on GitHub (Jun 2, 2022): As far as I understand the docs (https://cloud.google.com/storage/docs/object-versioning and https://cloud.google.com/storage/docs/metadata#generation-number) there is always a generation number returned, whether the versioning is enabled or not.
Author
Owner

@fsouza commented on GitHub (Jun 2, 2022):

As far as I understand the docs (https://cloud.google.com/storage/docs/object-versioning and https://cloud.google.com/storage/docs/metadata#generation-number) there is always a generation number returned, whether the versioning is enabled or not.

Oh gotcha, I missed this somehow. I guess we can always use the current time or something like that as the generation.

I'll try to take care of it over the coming weeks if no one beats me to it.

<!-- gh-comment-id:1144842242 --> @fsouza commented on GitHub (Jun 2, 2022): > As far as I understand the docs (https://cloud.google.com/storage/docs/object-versioning and https://cloud.google.com/storage/docs/metadata#generation-number) there is always a generation number returned, whether the versioning is enabled or not. Oh gotcha, I missed this somehow. I guess we can always use the current time or something like that as the generation. I'll try to take care of it over the coming weeks if no one beats me to it.
Author
Owner

@seniorcatDDL commented on GitHub (Jun 3, 2022):

I can help with this issue, if you tell me where to edit the server response please

<!-- gh-comment-id:1145791699 --> @seniorcatDDL commented on GitHub (Jun 3, 2022): I can help with this issue, if you tell me where to edit the server response please
Author
Owner

@fsouza commented on GitHub (Jun 4, 2022):

@veteran29 @seniorcatDDL I believe this is a limitation in the filesystem backend only? It should be solved when we fully implement versioning in that backend, but a quicker fix is available in #812. Could you give that a try?

Thanks for your patience!

<!-- gh-comment-id:1146513883 --> @fsouza commented on GitHub (Jun 4, 2022): @veteran29 @seniorcatDDL I believe this is a limitation in the filesystem backend only? It should be solved when we fully implement versioning in that backend, but a quicker fix is available in #812. Could you give that a try? Thanks for your patience!
Author
Owner

@fsouza commented on GitHub (Jun 5, 2022):

Closed via 230d2a3d35.

<!-- gh-comment-id:1146888225 --> @fsouza commented on GitHub (Jun 5, 2022): Closed via 230d2a3d35d32efcaa5450004792582ee539226e.
Author
Owner

@seniorcatDDL commented on GitHub (Jun 6, 2022):

Thank you, I'll definitely try it today

<!-- gh-comment-id:1147184059 --> @seniorcatDDL commented on GitHub (Jun 6, 2022): Thank you, I'll definitely try it today
Author
Owner

@seniorcatDDL commented on GitHub (Jun 6, 2022):

Works great, thanks a lot!
Is it possible to update a docker image?

<!-- gh-comment-id:1147284764 --> @seniorcatDDL commented on GitHub (Jun 6, 2022): Works great, thanks a lot! Is it possible to update a docker image?
Author
Owner

@fsouza commented on GitHub (Jun 6, 2022):

Is it possible to update a docker image?

Should be up in a couple of minutes, I made a mistake when tagging it yesterday. Sorry about that.

<!-- gh-comment-id:1147421243 --> @fsouza commented on GitHub (Jun 6, 2022): > Is it possible to update a docker image? Should be up in a couple of minutes, I made a mistake when tagging it yesterday. Sorry about that.
Author
Owner

@seniorcatDDL commented on GitHub (Jun 8, 2022):

Thanks a lot!

<!-- gh-comment-id:1149718293 --> @seniorcatDDL commented on GitHub (Jun 8, 2022): Thanks a lot!
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#119
No description provided.