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 — feat: add support for Etag headers on reads by daniellehanks · Pull Request #489 · googleapis/python-storage

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

Conversation

@daniellehanks

@daniellehanks daniellehanks commented Jul 6, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Support conditional requests based on ETag for read operations (reload, exists, download_*). My own testing seems to indicate that the JSON API does not support ETag If-Match/If-None-Match headers on modify requests (patch, delete, etc.), please correct me if I am mistaken.

This part two of #451. Part one in #488.
Fixes #451 🦕

Sorry, something went wrong.

Uh oh!

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

All reactions
daniellehanks added 8 commits July 5, 2021 22:06
@daniellehanks
Supports downloads conditional on etag
98fe6d6
@daniellehanks
Move etag parameter to header conversion to _helpers
9a41f9a
@daniellehanks
Support conditional by etag on Blob.exists
ab2a1e7
@daniellehanks
Support reload conditional on etag
c5b19d2
@daniellehanks
blacken
ef0d4e6
@daniellehanks
Support Bucket.exists conditional on etag
4d23548
@daniellehanks
Rename duplicate test
5336fd5
@daniellehanks
Pipe etag parameters through Bucket.get_blob
ce4d348
@product-auto-label product-auto-label Bot added the api: storage Issues related to the googleapis/python-storage API. label Jul 6, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 6, 2021
daniellehanks
daniellehanks commented Jul 6, 2021
View reviewed changes
Comment thread google/cloud/storage/_helpers.py Resolved

Uh oh!

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

@daniellehanks daniellehanks mentioned this pull request Jul 6, 2021
Support ETag headers #451
Closed
@tseaver tseaver changed the title Etag headers on reads feat: add support for Etag headers on reads Jul 6, 2021
tseaver
tseaver suggested changes Jul 6, 2021
View reviewed changes

@tseaver tseaver 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.

Thanks very much for the patch!

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/cloud/storage/_helpers.py Resolved

Uh oh!

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

Comment thread docs/generation_metageneration.rst Resolved

Uh oh!

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

Comment thread google/cloud/storage/_helpers.py Resolved

Uh oh!

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

Comment thread google/cloud/storage/blob.py Resolved

Uh oh!

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

Comment thread google/cloud/storage/bucket.py Resolved

Uh oh!

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

Comment thread tests/unit/test__helpers.py Resolved

Uh oh!

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

Comment thread tests/unit/test_blob.py Resolved

Uh oh!

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

Comment thread tests/unit/test_client.py Resolved

Uh oh!

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

@tseaver tseaver added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 6, 2021
@yoshi-kokoro yoshi-kokoro removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jul 6, 2021
@tseaver
Merge branch 'master' into etag-headers
2b4f7f4
@daniellehanks

daniellehanks commented Jul 6, 2021

Copy link
Copy Markdown
Contributor Author

Thanks very much for the patch!

Appreciate the preview review so I can address requested changes before writing system tests.

All reactions

Sorry, something went wrong.

Uh oh!

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

@daniellehanks
Address PR feedback
2f720e7
@daniellehanks

daniellehanks commented Jul 6, 2021

Copy link
Copy Markdown
Contributor Author

PR feedback addressed. Still need to add system tests. Hoping to find some time tonight.

All reactions

Sorry, something went wrong.

Uh oh!

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

daniellehanks
daniellehanks commented Jul 7, 2021
View reviewed changes
Comment thread google/cloud/storage/_helpers.py Resolved

Uh oh!

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

daniellehanks
daniellehanks commented Jul 7, 2021
View reviewed changes
Comment thread google/cloud/storage/_helpers.py
if value is not None:
if isinstance(value, str):
value = [value]
headers[header_name] = ", ".join(value)

@daniellehanks daniellehanks Jul 7, 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.

It seems to me (though I'm not a spec expert) that the GCS API isn't following spec putting quotes around the etag values. E.g. If-None-Match: COKaz4vVzfECEAE= works as intended but If-None-Match: "COKaz4vVzfECEAE=" does not. That said, the response header is also not quoted as it apparently should be etag: COKaz4vVzfECEAE= vs expected etag: "COKaz4vVzfECEAE=". Referencing this and this.

Sorry, something went wrong.

Uh oh!

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

All reactions

@daniellehanks daniellehanks Jul 7, 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.

Hmm, maybe its just the display layers or something (using Chrome dev tools and curl). Wikipedia does the same thing.

Sorry, something went wrong.

Uh oh!

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

All reactions

@daniellehanks daniellehanks Jul 7, 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.

microsoft.com has it quoted 🤔

Sorry, something went wrong.

Uh oh!

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

All reactions

@tseaver tseaver Jul 7, 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.

RFC 7232 is the actual authoritative spec for conditional HTTP requests: If-Match and If-None-Match. The Collected ABNF appendix does indeed seem to require the double quote.

The GCS docs for the ETag header show the quotes as well.

Sorry, something went wrong.

Uh oh!

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

All reactions

@daniellehanks daniellehanks Jul 7, 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.

Yep, all the examples in the spec are also quoted. Fun times. Definitely out of scope for this PR. Just wanted to call it out. I would think the etag itself should have the quotes (i.e. blob.etag = '"Csdlei="'), so then this code would still function correctly. Of course getting etags quoted would be a far larger change spanning the backend, possibly ESF, and probably a fair amount of Hyrum's law.

It just stood out to me because I ran into a similar problem implementing the UI for BigQuery, which also doesn't follow the etag spec. In the end it meant we couldn't cache tables in the UI. But we also couldn't change the API without risking breaking clients. I'll leave it up to you if you want to file an internal ticket for that.

Sorry, something went wrong.

Uh oh!

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

All reactions

@tseaver tseaver Jul 7, 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.

Effectively we're stuck with the as-implemented back-end. @frankyn, @andrewsg, @tswast I'll leave it to y'all to open a ticket on the back-end (if one isn't there already) for the out-of-spec behavior.

Sorry, something went wrong.

Uh oh!

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

daniellehanks reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
daniellehanks added 2 commits July 6, 2021 23:41
@daniellehanks
Add system test for client download conditional on etag
97f46c0
@daniellehanks
Add system test for blob crud with etag
db1ab12
@daniellehanks

daniellehanks commented Jul 7, 2021

Copy link
Copy Markdown
Contributor Author

I added two system tests. The first for the client as requested. The second for blob crud modeled after generation crud (but without write operations). There wasn't an existing system test for bucket metageneration stuff, so I didn't add one there for etags. Please let me know if there are any other tests you would like to see added.

I'm removing draft status as this PR is now complete from my perspective.

All reactions

Sorry, something went wrong.

Uh oh!

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

@daniellehanks
daniellehanks marked this pull request as ready for review July 7, 2021 05:59
@daniellehanks
daniellehanks requested review from a team and tseaver July 7, 2021 05:59
@daniellehanks
Make etag helper 2.7 compatible
7a03371
@daniellehanks

daniellehanks commented Jul 7, 2021

Copy link
Copy Markdown
Contributor Author

FYI I ran the system tests for 2.7 and caught a bug in the etag helper (instance check for str doesn't work for unicode type in 2.7) that the unit tests didn't catch (because they don't round trip the etag). Fixed by using six.string_types.

All reactions

Sorry, something went wrong.

Uh oh!

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

@daniellehanks
daniellehanks requested a review from tseaver July 7, 2021 20:00
@daniellehanks
Update second blob variable name
c388fe8
tseaver
tseaver approved these changes Jul 8, 2021
View reviewed changes
@tseaver tseaver added automerge Merge the pull request once unit tests and other checks pass. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jul 8, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 8, 2021
@tseaver
chore: blacken
6b3b6ab
@tseaver tseaver added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 8, 2021
@google-cla

google-cla Bot commented Jul 8, 2021

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

All reactions

Sorry, something went wrong.

Uh oh!

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

@google-cla google-cla Bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Jul 8, 2021
@tseaver

tseaver commented Jul 8, 2021

Copy link
Copy Markdown
Contributor

@googlebot I consent.

All reactions

Sorry, something went wrong.

Uh oh!

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

@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 8, 2021
@google-cla google-cla Bot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Jul 8, 2021
tseaver
tseaver reviewed Jul 8, 2021
View reviewed changes
Comment thread tests/system/test_client.py Resolved

Uh oh!

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

tseaver
tseaver suggested changes Jul 8, 2021
View reviewed changes
Comment thread tests/unit/test_client.py Resolved

Uh oh!

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

@tseaver
chore: remove unused import
3e32a3e
tseaver
tseaver approved these changes Jul 8, 2021
View reviewed changes
@tseaver tseaver added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 8, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 8, 2021
@gcf-merge-on-green
gcf-merge-on-green Bot merged commit 741d3fd into googleapis:master Jul 8, 2021
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jul 8, 2021
@tseaver

tseaver commented Jul 8, 2021

Copy link
Copy Markdown
Contributor

Thanks, again, @daniellehanks for your effort!

daniellehanks reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

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

cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
@daniellehanks @cojenco
feat: add support for Etag headers on reads (googleapis#489)
44b12a9
Support conditional requests based on ETag for read operations (`reload`, `exists`, `download_*`). My own testing seems to indicate that the JSON API does not support ETag If-Match/If-None-Match headers on modify requests (`patch`, `delete`, etc.), please correct me if I am mistaken.

This part two of googleapis#451. Part one in googleapis#488.
Fixes googleapis#451 🦕
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
@daniellehanks @cojenco
feat: add support for Etag headers on reads (googleapis#489)
b0a9d58
Support conditional requests based on ETag for read operations (`reload`, `exists`, `download_*`). My own testing seems to indicate that the JSON API does not support ETag If-Match/If-None-Match headers on modify requests (`patch`, `delete`, etc.), please correct me if I am mistaken.

This part two of googleapis#451. Part one in googleapis#488.
Fixes googleapis#451 🦕
@release-please release-please Bot mentioned this pull request Jan 12, 2022
chore(main): release 3.0.0 #688
Closed
@cojenco cojenco mentioned this pull request Apr 8, 2025
Add support for JSON API headers and query string parameters #30
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@tseaver tseaver tseaver 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.

Support ETag headers

Uh oh!

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

3 participants

@daniellehanks @tseaver @yoshi-kokoro
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.