You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently discovered a bug when trying to delete a doc from a CouchDB database. The action of deleting a document with "undefined" inputs actually removes the whole database. The .destroy() call should really be restricted to destroying documents and not the whole DB itself. If an undefined is sent in, I think nano should ideally return an error?
On close inspection, I found that the HTTP request that goes to the database if the id is undefined, is the same as the database delete request: { method: 'DELETE', headers: { 'content-type': 'application/json', accept: 'application/json' }, uri: 'https://{database-url}/{database-name}', qs: { rev: undefined } }
The two functions in nano, destroyDb and destroyDoc seem to build the same request URL when the ID is undefined.
Recently discovered a bug when trying to delete a doc from a CouchDB database. The action of deleting a document with "undefined" inputs actually removes the whole database. The .destroy() call should really be restricted to destroying documents and not the whole DB itself. If an undefined is sent in, I think nano should ideally return an error?
This is a sample code to reproduce what happens:
const nano = require( 'nano' )( CouchDB );
const dbName = nano.db.use( 'dbName' );
dbName.destroy( undefined, undefined, ( err ) => {
//DB is destroyed at this point
} );
The text was updated successfully, but these errors were encountered: