cloudant / nodejs-cloudant

Cloudant Node.js client library
Apache License 2.0
255 stars 90 forks source link

Inserting an array produces incorrect error "database does not exist." #410

Closed edshee closed 3 years ago

edshee commented 4 years ago

Please read these guidelines before opening an issue.

Bug Description

When using db.insert() with anything other than a valid JSON object. The error returned is as follows: name: 'Error', error: 'not_found', reason: 'Database does not exist.', scope: 'couch', statusCode: 404,

This is really misleading as it implies there is nothing wrong with the .insert() operation but that the database doesn't exist (when actually it does).

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

cloudant.use('mydb').insert([1,2,3,4],(err, data) => {if (err) {console.log(err);} else {console.log(data);}

2. What you expected to happen

Be returned the correct error e.g. "Document must be a valid JSON object"

3. What actually happened

Returned incorrect error "Database does not exist."

Environment details

ricellis commented 3 years ago

Closing; not reproducible - we always observe the correct Error: Document must be a JSON object when attempting this.

Our new cloudant-node-sdk(beta) also returns the correct error if using an array with either postDocument or putDocument examples.