GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: revise and rename is_etag_in_json(data) by cojenco · Pull Request #483 · googleapis/python-storage

This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Conversation

@cojenco

@cojenco cojenco commented Jun 28, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This PR revises and renames retry.is_etag_in_json(data) to ensure that eTags are correctly captured and validated from the request body.

  • Rename conditional retry predicate retry.is_etag_in_json(data) to retry.is_etag_in_data(data). It returns a boolean whether or not an etag is contained in the request body.
  • Revise retry.is_etag_in_data(data) to reflect library use cases in which data is dict or None
  • Update tests and docs

Fixes #481 🦕

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cojenco
fix: handle cases where data is a dict in is_etag_in_json(data)
d78e84d
@cojenco
cojenco requested review from a team June 28, 2021 19:32
@product-auto-label product-auto-label Bot added the api: storage Issues related to the googleapis/python-storage API. label Jun 28, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 28, 2021
@cojenco
Merge branch 'master' into etag_in_json
c1d6697
tritone
tritone reviewed Jun 29, 2021
View reviewed changes
Comment thread google/cloud/storage/retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

cojenco added 4 commits July 2, 2021 17:19
@cojenco
Merge branch 'master' into etag_in_json
3a1186d
@cojenco
address comments and accept proposed changes
73a9802
@cojenco
Merge branch 'master' into etag_in_json
1e59dbe
@cojenco
revise is_etag_in_json to check dict data
6e665ef
@cojenco
cojenco requested a review from tseaver July 9, 2021 16:54
@cojenco
Merge branch 'master' into etag_in_json
7f35d1a
tritone
tritone approved these changes Jul 9, 2021
View reviewed changes

@tritone tritone left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks much cleaner, thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/storage/retry.py Outdated
pass
return False
:type data: dict or None
:param data: A dict containing the JSON body. If not passed, returns False.

@tritone tritone Jul 9, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Nit: I think we could be clearer that the dict represents the JSON body rather than containing it. Also, this is specifically intended for calls where metadata is sent in the request body.

It seems like it'd be better to actually just rename this function to is_etag_in_data but I guess technically this is part of the public surface of the library (even if we don't expect external callers to use it directly)?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cojenco reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@tseaver tseaver Jul 9, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We could rename it and leave is_etag_in_json around as a backward-compatibility alias.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cojenco cojenco Jul 9, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Would it be something like this:

def is_etag_in_data(data):
    """Return True if an etag is contained in the request body.

    :type data: dict or None
    :param data: A dict representing the request JSON body. If not passed, returns False.
    """
    return data is not None and "etag" in data


def is_etag_in_json(data):
    """
    ``is_etag_in_json`` is supported for backwards-compatibility reasons only;
    please use ``is_etag_in_data`` instead.
    """
    return is_etag_in_data(data)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tseaver tseaver Jul 9, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cojenco
revise docstring wording
da23d13
tseaver
tseaver reviewed Jul 9, 2021
View reviewed changes
Comment thread google/cloud/storage/retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@cojenco
revise docstrings
ba3c16a
tritone
tritone approved these changes Jul 9, 2021
View reviewed changes
@cojenco
rename conditional predicate to is_etag_in_data
af0abb3
@cojenco cojenco changed the title fix: handle cases where data is a dict in is_etag_in_json(data) fix: revise and rename is_etag_in_json(data) Jul 9, 2021
@cojenco
cojenco merged commit 0a52546 into master Jul 9, 2021
@cojenco
cojenco deleted the etag_in_json branch July 9, 2021 22:21
cojenco added a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
@cojenco
fix: revise and rename is_etag_in_json(data) (googleapis#483)
42487ba
* fix: handle cases where data is a dict in is_etag_in_json(data)

* address comments and accept proposed changes

* revise is_etag_in_json to check dict data

* revise docstring wording

* revise docstrings

* rename conditional predicate to is_etag_in_data
cojenco added a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
@cojenco
fix: revise and rename is_etag_in_json(data) (googleapis#483)
4e3021f
* fix: handle cases where data is a dict in is_etag_in_json(data)

* address comments and accept proposed changes

* revise is_etag_in_json to check dict data

* revise docstring wording

* revise docstrings

* rename conditional predicate to is_etag_in_data
@release-please release-please Bot mentioned this pull request Jan 12, 2022
chore(main): release 3.0.0 #688
Closed
@andtrott andtrott mentioned this pull request Nov 27, 2024
Storage list_blobs iterator doesn't return prefixes #1388
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@tseaver tseaver tseaver left review comments
@tritone tritone tritone approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: storage Issues related to the googleapis/python-storage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Handle data dict type in retry.is_etag_in_json(data)

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@cojenco @tseaver @tritone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.