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

client.bucketExists inconsistent behavior #648

Closed
ruslan-polutsygan opened this issue Nov 16, 2017 · 8 comments
Closed

client.bucketExists inconsistent behavior #648

ruslan-polutsygan opened this issue Nov 16, 2017 · 8 comments
Assignees
Milestone

Comments

@ruslan-polutsygan
Copy link

ruslan-polutsygan commented Nov 16, 2017

Hello

If I configure minio.client with region - client.bucketExists throws error with e.code === 'NotFound'.

var client = new Minio.Client({
  endPoint: 'host',
  accessKey: 'ACCESSKEYID',
  secretKey: 'SECRETACCESSKEY'
})

client.bucketExists('bucketname', function(e) {
  if (e) {
    return console.log(e.code); /// 'NotFound'
  }
  console.log("True");
})

But if I minio.client configured without region - behavior is as documented.

var client = new Minio.Client({
  endPoint: 'host',
  accessKey: 'ACCESSKEYID',
  secretKey: 'SECRETACCESSKEY'
})

client.bucketExists('bucketname', function(e) {
  if (e) {
    return console.log(e.code); /// 'NoSuchBucket'
  }
  console.log("True")
})

Why is that?

@vadmeste
Copy link
Member

Hey @ruslan-polutsygan, does the bucket exist ?

@ruslan-polutsygan
Copy link
Author

Hi @vadmeste. No, it does not.

@ruslan-polutsygan
Copy link
Author

Besides,
The thing that client.bucketExists throws error - doesn't seems expected for me. Its name hints that either true or false has to be return. And situation "bucket doesn't exist" is not exceptional in this case, it is normal for this function. It(situation) is exceptional for any function that relies on bucket existence (put file, for example).
I understand it is not crucial issue, just FYI :)

@vadmeste
Copy link
Member

@ruslan-polutsygan, true/false is not enough.. because sometimes, we can have some errors like, network problem etc.. so we really need to return an error here.

By the way, are you testing against Minio or AWS S3 ?

@ruslan-polutsygan
Copy link
Author

ruslan-polutsygan commented Nov 16, 2017

Network problem - is exceptional situation for this case. From my perspective, this is the case for new Error

I'm testing with local minio server.

@vadmeste
Copy link
Member

Network problem - is exceptional situation for this case. From my perspective, this is the case for new Error

New() can be successful, but there is still chance to have network problem when you make the isBucketExist() call.

I'm testing with local minio server.

Thanks, will test it.. and compare Minio & AWS S3 behavior.. and see what S3 spec tells exactly.

@ruslan-polutsygan
Copy link
Author

ruslan-polutsygan commented Nov 16, 2017

New() can be successful, but there is still chance to have network problem when you make the isBucketExist() call.

Sorry, I mean that "network problem" is exceptional situation and error should be thrown in this case, but "bucket does not exist" - not exceptional for this method, it is expected. Nevermind, it's philosophical :)

will test it

Thank you.

@dcharbonnier
Copy link
Contributor

completely agree with @ruslan-polutsygan if should be possible to write

try {
   const exists = await client.bucketExists('bucketname');
   if(!exists) {
       await client.createBucket('bucketname');
   }
} catch(e) {
   console.log("error", e);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants