apache / nano

Nano is now part of Apache CouchDB. Repo moved to https://GitHub.com/apache/couchdb-nano

Home Page:https://github.com/apache/couchdb-nano

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

500 badarg on DELETE method?

JohnMcLear opened this issue · comments

Attempting to do

    db.destroy(key, header.etag, function(er, body) {
      if (er) return callback(er);
      callback(null);
    });

With values:
Key: sessionstorage:W65rYiVuXbNOuDum3CbpCOGOViB58TUn
header.etag 132-52fe339b5a391af0367c10eeac740980

Returns:

[2016-03-24 11:06:30.860] [INFO] console - err { [Error: badarg]
  name: 'Error',
  error: 'unknown_error',
  reason: 'badarg',
  scope: 'couch',
  statusCode: 500,
  request: 
   { method: 'DELETE',
     headers: 
      { 'content-type': 'application/json',
        accept: 'application/json' },
     uri: 'http://localhost:5984/etherpad/sessionstorage%3AW65rYiVuXbNOuDum3CbpCOGOViB58TUn',
     qs: { rev: '"132-52fe339b5a391af0367c10eeac740980"' } },
  headers: 
   { date: 'Thu, 24 Mar 2016 11:06:30 GMT',
     'content-type': 'application/json',
     'cache-control': 'must-revalidate',
     statusCode: 500,
     uri: 'http://localhost:5984/etherpad/sessionstorage%3AW65rYiVuXbNOuDum3CbpCOGOViB58TUn' },
  errid: 'non_200',
  description: 'couch returned 500' }
Error: badarg
    at Request._callback (/home/jose/etherpad-lite/src/node_modules/ueberdb2/node_modules/nano/lib/nano.js:248:15)
    at Request.self.callback (/home/jose/etherpad-lite/src/node_modules/request/request.js:368:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/home/jose/etherpad-lite/src/node_modules/request/request.js:1219:14)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/home/jose/etherpad-lite/src/node_modules/request/request.js:1167:12)
    at emitNone (events.js:72:20)

Caused by URI encoding of key? The lack of error is making it hard to debug ;/ Thanks!

Nevermind I noticed the additional " and stripped them out...

You need to JSON.parse(header.etag).

In the error trace you can see additional quoites around the rev:

     qs: { rev: '"132-52fe339b5a391af0367c10eeac740980"' } }

Concurrent post :)