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

storage: some acl methods fail on empty (private) acl #652

Closed
pdknsk opened this issue Feb 16, 2015 · 4 comments · Fixed by #682
Closed

storage: some acl methods fail on empty (private) acl #652

pdknsk opened this issue Feb 16, 2015 · 4 comments · Fixed by #682
Assignees
Labels
api: storage Issues related to the Cloud Storage API.

Comments

@pdknsk
Copy link

pdknsk commented Feb 16, 2015

Easiest to set this up with gsutil. Please notice the verbose message.

$ gsutil defacl set private gs://bucket
Setting default object ACL on gs://bucket/...
$ gsutil defacl get gs://bucket
No default object ACL present for gs://bucket. This could occur if the default object ACL is private, in which case objects created in this bucket will be readable only by their creators.
[]

In particular acl.reload and acl.save don't work, probably others too.

>>> acl = storage.acl.DefaultObjectACL(bucket)
>>> acl.get_entities()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python2.7/site-packages/gcloud/storage/acl.py", line 358, in get_entities
    self._ensure_loaded()
  File "/home/user/.local/lib/python2.7/site-packages/gcloud/storage/acl.py", line 192, in _ensure_loaded
    self.reload()
  File "/home/user/.local/lib/python2.7/site-packages/gcloud/storage/acl.py", line 409, in reload
    for entry in found['items']:
KeyError: 'items'
>>> acl.get_entities()
[]
>>> acl.reload()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python2.7/site-packages/gcloud/storage/acl.py", line 409, in reload
    for entry in found['items']:
KeyError: 'items'
>>> acl.save()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python2.7/site-packages/gcloud/storage/acl.py", line 453, in save
    for entry in result[self._URL_PATH_ELEM]:
KeyError: 'defaultObjectAcl'

This works fine if the default ACL is set to project-private rather than private.

@dhermes
Copy link
Contributor

dhermes commented Feb 17, 2015

@pdknsk Thanks again for the great report!

I don't fully understand the meaning of private

It seems this is fixed easily by replacing found['items'] with found.get('items', []) and replacing result[self._URL_PATH_ELEM] with result.get(self._URL_PATH_ELEM, []).


Clarification: Are you authorized as yourself via gsutil when setting private?

Are you authorized as a service account when using gcloud-python?

@dhermes dhermes added the api: storage Issues related to the Cloud Storage API. label Feb 18, 2015
@dhermes dhermes modified the milestone: Storage Stable Feb 18, 2015
@pdknsk
Copy link
Author

pdknsk commented Feb 19, 2015

It's a predefined ACL. I use the same owner account for both, set up with gcloud auth.

@dhermes
Copy link
Contributor

dhermes commented Feb 19, 2015

@pdknsk Do you use gcloud auth with a user account (e.g. [email protected]) and then use a service account with gcloud-python?

@pdknsk
Copy link
Author

pdknsk commented Feb 19, 2015

Nope, it's a user account in both cases.

@tseaver tseaver self-assigned this Feb 26, 2015
tseaver added a commit that referenced this issue Feb 26, 2015
#652: Harden ACL 'save'/'reload' against missing element in server response.
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 Cloud Storage API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants