[GH-ISSUE #416] deleted metadata always returned even when it shouldn't exist #81

Closed
opened 2026-03-03 12:08:06 +03:00 by kerem · 1 comment
Owner

Originally created by @oittaa on GitHub (Feb 6, 2021).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/416

  1. Create an object.
  2. Fetch it and see that there's "deleted":"0001-01-01T00:00:00Z"

Python even throws an error ValueErroras it doesn't match with the regex.

https://cloud.google.com/storage/docs/json_api/v1/objects

"The deletion time of the object in RFC 3339 format. Returned if and only if this version of the object is no longer a live version, but remains in the bucket as a noncurrent version."

from google.auth.credentials import AnonymousCredentials
from google.cloud import storage
 
client = storage.Client(
    credentials=AnonymousCredentials(),
    project="test",
)
 
bucket_name = "test-bucket"
blob_name = "test_blob"
 
bucket = client.get_bucket(bucket_name)
 
blob = bucket.blob(blob_name)
print("Before upload {}".format(blob.time_deleted))
blob.upload_from_string("test")
blob.reload()
print("After upload {}".format(blob.time_deleted))

Output

Before upload None
Traceback (most recent call last):
  File "test.py", line 18, in <module>
    print("After upload {}".format(blob.time_deleted))
  File "/home/user/venv/lib/python3.8/site-packages/google/cloud/storage/blob.py", line 3730, in time_deleted
    return _rfc3339_to_datetime(value)
  File "/home/user/venv/lib/python3.8/site-packages/google/cloud/_helpers.py", line 286, in _rfc3339_to_datetime
    return datetime.datetime.strptime(dt_str, _RFC3339_MICROS).replace(tzinfo=UTC)
  File "/usr/lib/python3.8/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/lib/python3.8/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '0001-01-01T00:00:00Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'
Originally created by @oittaa on GitHub (Feb 6, 2021). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/416 1. Create an object. 2. Fetch it and see that there's `"deleted":"0001-01-01T00:00:00Z"` Python even throws an error `ValueError`as it doesn't match with the regex. https://cloud.google.com/storage/docs/json_api/v1/objects "The deletion time of the object in RFC 3339 format. Returned if and only if this version of the object is no longer a live version, but remains in the bucket as a noncurrent version." ```python from google.auth.credentials import AnonymousCredentials from google.cloud import storage client = storage.Client( credentials=AnonymousCredentials(), project="test", ) bucket_name = "test-bucket" blob_name = "test_blob" bucket = client.get_bucket(bucket_name) blob = bucket.blob(blob_name) print("Before upload {}".format(blob.time_deleted)) blob.upload_from_string("test") blob.reload() print("After upload {}".format(blob.time_deleted)) ``` #### Output ``` Before upload None Traceback (most recent call last): File "test.py", line 18, in <module> print("After upload {}".format(blob.time_deleted)) File "/home/user/venv/lib/python3.8/site-packages/google/cloud/storage/blob.py", line 3730, in time_deleted return _rfc3339_to_datetime(value) File "/home/user/venv/lib/python3.8/site-packages/google/cloud/_helpers.py", line 286, in _rfc3339_to_datetime return datetime.datetime.strptime(dt_str, _RFC3339_MICROS).replace(tzinfo=UTC) File "/usr/lib/python3.8/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) File "/usr/lib/python3.8/_strptime.py", line 349, in _strptime raise ValueError("time data %r does not match format %r" % ValueError: time data '0001-01-01T00:00:00Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ' ```
kerem 2026-03-03 12:08:06 +03:00
Author
Owner

@fsouza commented on GitHub (Feb 15, 2021):

Thanks for reporting. If I remember correctly, we saw this issue with other datetime fields. Probably something we missed in deleted.

<!-- gh-comment-id:779476389 --> @fsouza commented on GitHub (Feb 15, 2021): Thanks for reporting. If I remember correctly, we saw this issue with other datetime fields. Probably something we missed in `deleted`.
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#81
No description provided.