appengine-gcs-client icon indicating copy to clipboard operation
appengine-gcs-client copied to clipboard

Bug: cloudstorage.open() writes to the options dictionary passed as parameter

Open katzlbt opened this issue 10 years ago • 0 comments

I use a dict datastructure to store permission sets that should be CONSTANT and pass it to cloudstorage.* functions. Some cloudstorage functions write to this permission set and modify it. This changes my constant GCS_ACL_OPTIONS['public'] and adds options that cause the ValueError.

GCS_ACL_OPTIONS = {
    "public": {'x-goog-acl': 'public-read'},
    "private": {'x-goog-acl': 'private'},

# Fails
ostream = cloudstorage.open(filename, content_type='application/json', mode='w',
                                options=GCS_ACL_OPTIONS[permission])
# Works
ostream = cloudstorage.open(filename, content_type='application/json', mode='w',
                                options={'x-goog-acl': 'public-read'})

Alternates: ValueError: option x-goog-api-version is not supported. ValueError: option x-goog-metadata-directive is not supported.

File "distlib/cloudstorage/cloudstorage_api.py", line 94, in open common.validate_options(options) File "distlib/cloudstorage/common.py", line 308, in validate_options raise ValueError('option %s is not supported.' % k) ValueError: option x-goog-copy-source is not supported.

katzlbt avatar Jul 28 '15 22:07 katzlbt