13
votes

I am trying to create a bucket using gsutil mb command:

gsutil mb -c DRA -l US-CENTRAL1 gs://some-bucket-to-my-gs

But I am getting this error message:

Creating gs://some-bucket-to-my-gs/...
BadRequestException: 400 Invalid argument.

I am following the documentation from here

What is the reason for this type of error?

6
I just copied and pasted your command, changed the bucket name, and then ran it and it worked, and created the bucket. - IanGSY
The documentation for the error codes, although not helpful in this case, is here: developers.google.com/storage/docs/… - IanGSY
I tried with different bucket names and also with different options. nothing worked for me so far. But I can use other gsutil commands like rsync. But not sure why this gsutil mb command is not working! - K M Rakibul Islam
When did you last update it, try "gsutil version" to see which version you have, I have 4.1 - IanGSY
Do you have billing enabled? - IanGSY

6 Answers

12
votes

One reason this error can occur (confirmed in chat with the question author) is that you have an invalid default_project_id configured in your .boto file. Ensure that ID matches your project ID in the Google Developers Console

If you can make a bucket successfully using the Google Developers Console, but not using "gsutil mb", this is a good thing to check.

14
votes

I got the same error. I was because I used the wrong location. The location parameter expects a region without specifying witch zone.

Eg.

sutil mb -p ${TF_ADMIN} -l europe-west1-b  gs://${TF_ADMIN}

Should have been

sutil mb -p ${TF_ADMIN} -l europe-west1  gs://${TF_ADMIN}
2
votes

I was receiving the same error for the same command while using gsutil as well as the web console. Interestingly enough, changing my bucket name from "google-gatk-test" to "gatk" allowed the request to go through. The original name does not appear to violate bucket naming conventions.

Playing with the bucket name is worth trying if anyone else is running into this issue.

0
votes

Got this error and adding the default_project_id to the .boto file didn't work. Took me some time but at the end i deleted the credentials file from the "Global Config" directory and recreated the account.

Using it on windows btw...

0
votes

This can happen if you are logged into the management console (storage browser), possibly a locking/contention issue.

May be an issue if you add and remove buckets in batch scripts.

In particular this was happening to me when creating regionally diverse (non DRA) buckets :

gsutil mb -l EU gs://somebucket

Also watch underscores, the abstraction scheme seems to use them to map folders. All objects in the same project are stored at the same level (possibly as blobs in an abstracted database structure).

You can see this when downloading from the browser interface (at the moment anyway).

An object copied to gs://somebucket/home/crap.txt might be downloaded via a browser (or curl) as home_crap.txt. As a an aside (red herring) somefile.tar.gz can come down as somefile.tar.gz.tar so a little bit of renaming may be required due to the vagaries of the headers returned from the browser interface anyway. Min real support level is still $150/mth.

0
votes

I had this same issue when I created my bucket using the following commands

MY_BUCKET_NAME_1=quiceicklabs928322j22df
MY_BUCKET_NAME_2=MY_BUCKET_NAME_1
MY_REGION=us-central1

But when I decided to add dollar sign $ to the variable MY_BUCKET_NAME_1 as MY_BUCKET_NAME_2=$MY_BUCKET_NAME_1 the error was cleared and I was able to create the bucket