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 2019/09/26 13:23:19 UTC

[GitHub] [couchdb] vmatyusGitHub opened a new issue #2209: Cannot get 417 error code for _bulk_doc endpoint with validation

vmatyusGitHub opened a new issue #2209: Cannot get 417 error code for _bulk_doc endpoint with validation 
URL: https://github.com/apache/couchdb/issues/2209
 
 
   [NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^ )
   
   ## Description
   During the tesing of `_bulk_docs` endpoint I could not manage to get 
   417 (Expectation Failed) response from CouchDB. However I reproduced
   document validation error as the documentation stated here: http://docs.couchdb.org/en/2.0.0/api/database/bulk-api.html#post--db-\_bulk\_docs
   A documentation validation error occured, but the CouchDB answer remained 201, not changed to 417.
   
   I could not decide whether this documentation or CouchDB issue. 
   
   [NOTE]: # ( Describe the problem you're encountering. )
   [TIP]:  # ( Do NOT give us access or passwords to your actual CouchDB! )
   
   ## Steps to Reproduce
   [NOTE]: # ( Include commands to reproduce, if possible. curl is preferred. )
   1. Create a validation document:
   ```
   {
     "_id": "_design/validation",
     "_rev": "2-1c951cf2c4f20390a2e2527ddc0ca40d",
     "validate_doc_update": "function(newDoc) { 
                 if(newDoc.sales > 20) {
                       throw({ forbidden: 'Impossible value.'})
                 }
            }"
   }
   ```
   2. Update an existing document with invalid value:
   ```
   {
     "docs": [
         {
           "_id": "sales1",
           "_rev": "1-156c36a09be5d5ddfaf095f8add6d5da",
           "sales": 25
         }
       ]
   }
   ```
   ## Expected Behaviour
   According to documentation the CouchDB should answer with 417 error code, but now it is 201.
   The content of the response body is appropriate:
   ```
   [
     {
       "id": "sales1",
       "error": "forbidden",
       "reason": "Impossible value."
     }
   ]
   ```
   
   [NOTE]: # ( Tell us what you expected to happen. )
   
   ## Your Environment
   
   [TIP]:  # ( Include as many relevant details about your environment as possible. )
   [TIP]:  # ( You can paste the output of curl http://YOUR-COUCHDB:5984/ here. )
   
   * CouchDB Version used: 2.3.1
   * Browser name and version: Postman
   * Operating System and version: Linux
   
   ## Additional context
   
   [TIP]:  # ( Add any other context about the prbolem here. )
   Please decide the correction where is necessary, in the documentation or in the CouchDB.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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