You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2017/11/27 18:23:18 UTC

[GitHub] stickbyatlas opened a new issue #1021: CouchDB 2.1: _users database update handlers always invoked with null first parameter

stickbyatlas opened a new issue #1021: CouchDB 2.1: _users database update handlers always invoked with null first parameter
URL: https://github.com/apache/couchdb/issues/1021
 
 
   ## Expected Behavior
   
   In the latest version of CouchDB, I have a design document in the _users database where I've defined several update handlers to modify user documents. These handlers should either accept an existing document (by providing the ID to the API endpoint) or create a new document (if no ID is supplied).
   
   ## Current Behavior
   
   In version 2.1.0 of CouchDB, running via the binary on OS X Sierra, these update handlers are always being invoked with `null` as the first parameter to the function. This happens whether I provide a document ID or not.
   
   ## Steps to Reproduce (for bugs)
   1. Create a design document `test` in the `_users` database with an `updates` key, and define a function `test` with the signature `function(doc, req)`
   2. In the body of the function: `return [null, JSON.stringify(doc)]`
   ```javascript
   {
     "_id": "_design/test",
     "updates": {
       "test": "function(doc,req){return [null, JSON.stringify(doc)]}"
     }
   }
   ```
   3. Invoke the update handler: 
   `curl -X POST http://<admin>:<pass>:127.0.0.1:5984/_users/_design/test/_update/test/org.couchdb.user:<username>`
   4. Note that the response for this function is `null`, not the document's JSON.
   
   ## Context
   
   I use these update handlers to modify properties on user accounts on behalf of these users, using middleware, so that I can revoke or grant privileges, etc. It made sense to keep the logic for this within CouchDB itself, rather than embedding the code in my application logic.
   
   ## Your Environment
   * Version used: 2.1.0
   * Browser Name and version: curl / Safari
   * Operating System and version (desktop or mobile): Apache CouchDB binary running on OS X High Sierra
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services