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

docs: add docs signed_url expiration take default utc #250

Merged
merged 9 commits into from
Aug 27, 2020

Conversation

HemangChothani
Copy link
Contributor

Fixes #244

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 19, 2020
Copy link
Contributor

@tseaver tseaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change all the docstrings as noted in my first comment.

:param expiration: Point in time when the signed URL should expire.
:param expiration: Point in time when the signed URL should expire. If
expiration in datetime, then need to pass timezone
with it. Default value of ``tzinfo`` is ``UTC``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value of the tzinfo argument to datetime.datetime is None, resulting in a "naive" datetime instance: the comment should state clearly that we forcibly convert such instances to UTC. E.g.:

    :param expiration: Point in time when the signed URL should expire. If
                       a `datetime` instance is passed without an explicit
                      `tzinfo` set,  it will be converted to ``UTC``.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than "it will be converted to" let's use "it will be assumed to be". This is a huge footgun; a user who sees the term "converted" will assume that we will do the right thing in the default case, whereas in fact we will almost always do the wrong thing.

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/python-storage API. label Aug 21, 2020
@frankyn frankyn requested a review from andrewsg August 24, 2020 21:11
Copy link
Contributor

@andrewsg andrewsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the original issue, can we also modify the system test TestV4POSTPolicies.test_get_signed_policy_v4() to use utcnow()?

@andrewsg
Copy link
Contributor

Cancel that, I just saw that the test issue is resolved in #251. Thanks for that! Leaving review on "changes requested" for the docstring update as per my comment; lgtm other than that.

Copy link
Contributor

@andrewsg andrewsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

google/cloud/storage/_signing.py Outdated Show resolved Hide resolved
google/cloud/storage/_signing.py Outdated Show resolved Hide resolved
google/cloud/storage/_signing.py Outdated Show resolved Hide resolved
google/cloud/storage/_signing.py Outdated Show resolved Hide resolved
google/cloud/storage/blob.py Outdated Show resolved Hide resolved
google/cloud/storage/bucket.py Outdated Show resolved Hide resolved
google/cloud/storage/client.py Outdated Show resolved Hide resolved
@tseaver
Copy link
Contributor

tseaver commented Aug 26, 2020

@HemangChothani I would merge my suggestions to address the concern expressed by @andrewsg , but you have the "maintainers can push changes" option turned off.

@tseaver tseaver merged commit 944ab18 into googleapis:master Aug 27, 2020
@IlyaFaer IlyaFaer deleted the storage_issue_244 branch September 10, 2020 14:22
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
Co-authored-by: Frank Natividad <frankyn@users.noreply.github.com>
Co-authored-by: Tres Seaver <tseaver@palladion.com>
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
Co-authored-by: Frank Natividad <frankyn@users.noreply.github.com>
Co-authored-by: Tres Seaver <tseaver@palladion.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generate_signed_post_policy_v4() improperly handles expiration timestamps with tzinfo=None
4 participants