minio-js icon indicating copy to clipboard operation
minio-js copied to clipboard

removeObjects did not throw an error

Open victimsss opened this issue 2 years ago • 5 comments

version:7.1.1

When the minio client is invalid, such as endPoint or port error, or even the minio service is not running, calling this API will not throw an error. I haven't checked other APIs for the time being. I hope the bug can be fixed in time.

case: `var Minio = require('minio')

var minioClient = new Minio.Client({ endPoint: '192.168.128.109', // Any invalid IP port: 9000, useSSL: true, accessKey: 'Q3AM3UQ867SPQQA43P2F', secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG' }) minioClient.removeObjects(bucket, target, (e) => { if (e) { return console.log('Unable to remove Objects ', e) } console.log('Removed the objects successfully') })`

victimsss avatar Jul 04 '23 08:07 victimsss

@victimsss

by default the client does not have a timeout. you could try setting minioClient.setRequestOptions({timeout:500}) if this is set, you would get error for client initilaization. e.g:

connect ETIMEDOUT 12.84.9.111:22000 

then for removeObject with invalid bucket, it will throw error.

 mc.removeObject("test", "test", (e, res) => {
    console.log(e.message, res)

  })
//e.g invalid bucket.
The specified bucket does not exist

if invalid/non-existent object is passed, it would always return 204 or 200 OK

So it is working as expected.

prakashsvmx avatar Jul 04 '23 09:07 prakashsvmx

@victimsss

by default the client does not have a timeout. you could try setting minioClient.setRequestOptions({timeout:500}) if this is set, you would get error for client initilaization. e.g:

connect ETIMEDOUT 12.84.9.111:22000 

then for removeObject with invalid bucket, it will throw error.

 mc.removeObject("test", "test", (e, res) => {
    console.log(e.message, res)

  })
//e.g invalid bucket.
The specified bucket does not exist

if invalid/non-existent object is passed, it would always return 204 or 200 OK

So it is working as expected.

removeObjects, not removeObject.

victimsss avatar Jul 04 '23 10:07 victimsss

with removeObjects the errors if any are returned for each individual objects. as part of res and not as part of e . so the please take a look.

const deleteList = [
  { name: 'non-existent' },
  { name: '0.txt' },
  { name: 'does not exist object2' },
  { name: '1.txt' },
  { name: '2.txt' },
  { name: 'does not exist object1110' }
]

mc.removeObjects("test-bucket", deleteList ,(e, res) => {

        if (e) {
          return console.log(e)
        }
        console.log("Success", res)
// Note : Inspect the res to find out if an object deletion is success or failure.

      })

e.g:

 [
  {
    Code: 'AccessDenied',
    Message: 'Access Denied.',
    Key: 'non-existent',
    VersionId: ''
  },
  {
    Code: 'AccessDenied',
    Message: 'Access Denied.',
    Key: '0.txt',
    VersionId: ''
  },
  {
    Code: 'AccessDenied',
    Message: 'Access Denied.',
    Key: 'does not exist object2',
    VersionId: ''
  },
  {
    Code: 'AccessDenied',
    Message: 'Access Denied.',
    Key: '1.txt',
    VersionId: ''
  },
  {
    Code: 'AccessDenied',
    Message: 'Access Denied.',
    Key: '2.txt',
    VersionId: ''
  },
  {
    Code: 'AccessDenied',
    Message: 'Access Denied.',
    Key: 'does not exist object1110',
    VersionId: ''
  }
]


prakashsvmx avatar Jul 04 '23 10:07 prakashsvmx

When the minio client is invalid, such as endPoint or port error, or even the minio service is not running, calling this API will not throw an error. I haven't checked other APIs for the time being. I hope the bug can be fixed in time.

When the minio client is invalid, such as endPoint or port error, or even the minio service is not running, calling this API will not throw an error. I haven't checked other APIs for the time being. I hope the bug can be fixed in time. image expect:connect ETIMEDOUT 12.84.9.111:22000 actual: Removed the objects successfully

I think you should try stopping the minio service and running the test case again

victimsss avatar Jul 04 '23 10:07 victimsss

We will check and send a fix for this scenario

minio.js Line 1207 needs a fix like:

 (e) => {
        if (e) {
          return cb(e, null)
        }
        return cb(null, _.flatten(batchResults))
      },

prakashsvmx avatar Jul 04 '23 11:07 prakashsvmx