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

removeObjects did not throw an error #1181

Open
victimsss opened this issue Jul 4, 2023 · 5 comments
Open

removeObjects did not throw an error #1181

victimsss opened this issue Jul 4, 2023 · 5 comments

Comments

@victimsss
Copy link

victimsss commented Jul 4, 2023

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')
})`

@prakashsvmx
Copy link
Member

@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.

@victimsss
Copy link
Author

@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.

@prakashsvmx
Copy link
Member

prakashsvmx commented Jul 4, 2023

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: ''
  }
]

@victimsss
Copy link
Author

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

@prakashsvmx prakashsvmx reopened this Jul 4, 2023
@prakashsvmx
Copy link
Member

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))
      },

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

No branches or pull requests

2 participants