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 blob.patch() returns 400 error on GCE only #1670

Closed
ndenny opened this issue Mar 28, 2016 · 9 comments
Closed

Storage blob.patch() returns 400 error on GCE only #1670

ndenny opened this issue Mar 28, 2016 · 9 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API.

Comments

@ndenny
Copy link

ndenny commented Mar 28, 2016

This may be related to #1185 - I'm seeing the following code work on my dev machine, but it's failing on GCE / Python 2.7.9 / gcloud 0.11.0:

from gcloud import storage
client = storage.Client()
bucket = client.bucket('my-bucket-name')
blob = bucket.blob('test.txt')
blob.upload_from_string('Hello world')
blob.metadata = {'luke': 'skywalker'}
blob.patch()

I get the following traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/gcloud/storage/_helpers.py", line 124, in patch
    query_params={'projection': 'full'}, _target_object=self)
  File "/usr/local/lib/python2.7/dist-packages/gcloud/connection.py", line 343, in api_request
    error_info=method + ' ' + url)
gcloud.exceptions.BadRequest: 400 Invalid argument. (PATCH https://www.googleapis.com/storage/v1/b/my-bucket-name/o/test.txt?projection=full)
@dhermes dhermes added the api: storage Issues related to the Cloud Storage API. label Mar 29, 2016
@dhermes
Copy link
Contributor

dhermes commented Mar 29, 2016

Strange that it would fail on one machine and not another, since it seems the error is about the payload. What OS are you using on GCE? I seem to recall your local dev machine is OS X?

@ndenny
Copy link
Author

ndenny commented Mar 29, 2016

Dev machine - Mac OS X:
Darwin 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64

GCE - fairly sure this is a "default" Debian setup:
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u3 (2016-01-17) x86_64 GNU/Linux
Machine type: n1-standard-1 (1 vCPU, 3.75 GB memory)
CPU platform: Intel Ivy Bridge
Zone: us-central1-f

@theacodes
Copy link
Contributor

Is this the same problem of the cloud-platform scope not being treated the same as dev_access.full_control and not letting you do PATCH requests?

@ndenny can you confirm which scopes your instance has?

@ndenny
Copy link
Author

ndenny commented Apr 5, 2016

I created the instance a while ago now... it's reporting this:

      "scopes": [
        "https://www.googleapis.com/auth/userinfo.email",
        "https://www.googleapis.com/auth/cloud.useraccounts.readonly",
        "https://www.googleapis.com/auth/devstorage.read_write",
        "https://www.googleapis.com/auth/datastore",
        "https://www.googleapis.com/auth/logging.write",
        "https://www.googleapis.com/auth/monitoring.write",
        "https://www.googleapis.com/auth/pubsub"
      ]

@theacodes
Copy link
Contributor

Gotcha. Can you try creating a new instance with the cloud-platform scope and trying again? Failing that, try creating one with devstorage.full_control?

@ndenny
Copy link
Author

ndenny commented Apr 8, 2016

Update: including devstorage.full_control has worked and solves the problem.
I was using the web console to create the instance, don't see a way to include cloud-platform, will look into using a command-line instead.

@theacodes
Copy link
Contributor

Cool, I guess that answers that. I'm going to go ahead and close this issue, but feel free to let us know if there's anything else we can do to help.

IAM is in the process of rolling out and will eventually supercede the need for scopes.

@ndenny
Copy link
Author

ndenny commented Apr 8, 2016

Glad we found a solution. Just for completeness, adding cloud-platform also fixed the issue.

@dhermes
Copy link
Contributor

dhermes commented Apr 8, 2016

Thanks for the follow up!

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

No branches or pull requests

3 participants