Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6124110664 for ; Mon, 17 Jun 2013 09:43:25 +0000 (UTC) Received: (qmail 77408 invoked by uid 500); 17 Jun 2013 09:43:24 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 77344 invoked by uid 500); 17 Jun 2013 09:43:21 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 77332 invoked by uid 99); 17 Jun 2013 09:43:20 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jun 2013 09:43:20 +0000 Date: Mon, 17 Jun 2013 09:43:20 +0000 (UTC) From: "Robert Newson (JIRA)" To: dev@couchdb.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (COUCHDB-1772) Invalid response to _bulk_docs with "all_or_nothing":true if validation fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-1772?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Robert Newson updated COUCHDB-1772: ----------------------------------- Summary: Invalid response to _bulk_docs with "all_or_nothing":true if validation fails (was: Invalid response to _bulk_update&all_or_nothing=true) > Invalid response to _bulk_docs with "all_or_nothing":true if validation fails > ----------------------------------------------------------------------------- > > Key: COUCHDB-1772 > URL: https://issues.apache.org/jira/browse/COUCHDB-1772 > Project: CouchDB > Issue Type: Bug > Components: Database Core > Affects Versions: 1.3 > Reporter: Leonid Usov > Attachments: 1772.patch > > > When a document fails custom validation function while performing bulk document update with a all_or_nothing flag set the server responds with an ill-formed document revision id > validation function: > function (newDoc, oldDoc, userCtx) { > if(newDoc.v && newDoc.v === 666){ > throw({forbidden: '666'}); > } > } > on a database 'test', using couchdb-python > >>> doc={} > >>> test.save(doc) > ('04da7996f6503fca300cda889fd6e375', '1-967a00dff5e02add41819138abb3284d') > >>> doc['v']=666 > >>> test.save(doc) > Gives 403 error > >>> test.update([doc]) > [(False, '04da7996f6503fca300cda889fd6e375', ServerError('666',))] > Seems fine, too > >>> test.update([doc], all_or_nothing=True) > Now this gives exception in python that it can't parse json. > >>> UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 51: invalid start byte > the TCP stream: > =================================== > POST /test HTTP/1.1 > Host: 192.168.1.1:5984 > Transfer-Encoding: chunked > Accept: application/json > User-Agent: CouchDB-Python/0.9dev > Content-Type: application/json > 2 > {} > 0 > HTTP/1.1 201 Created > Server: CouchDB/1.3.0 (Erlang OTP/R15B) > Location: http://192.168.1.1:5984/test/04da7996f6503fca300cda889fd6e375 > ETag: "1-967a00dff5e02add41819138abb3284d" > Date: Tue, 16 Apr 2013 12:34:25 GMT > Content-Type: application/json > Content-Length: 95 > Cache-Control: must-revalidate > {"ok":true,"id":"04da7996f6503fca300cda889fd6e375","rev":"1-967a00dff5e02add41819138abb3284d"} > PUT /test/04da7996f6503fca300cda889fd6e375 HTTP/1.1 > Host: 192.168.1.1:5984 > Transfer-Encoding: chunked > Accept: application/json > User-Agent: CouchDB-Python/0.9dev > Content-Type: application/json > 63 > {"_rev": "1-967a00dff5e02add41819138abb3284d", "_id": "04da7996f6503fca300cda889fd6e375", "v": 666} > 0 > HTTP/1.1 403 Forbidden > Server: CouchDB/1.3.0 (Erlang OTP/R15B) > Date: Tue, 16 Apr 2013 12:34:58 GMT > Content-Type: application/json > Content-Length: 37 > Cache-Control: must-revalidate > {"error":"forbidden","reason":"666"} > POST /test/_bulk_docs HTTP/1.1 > Host: 192.168.1.1:5984 > Transfer-Encoding: chunked > Accept: application/json > User-Agent: CouchDB-Python/0.9dev > Content-Type: application/json > 6f > {"docs": [{"_rev": "1-967a00dff5e02add41819138abb3284d", "_id": "04da7996f6503fca300cda889fd6e375", "v": 666}]} > 0 > HTTP/1.1 201 Created > Server: CouchDB/1.3.0 (Erlang OTP/R15B) > Date: Tue, 16 Apr 2013 12:36:29 GMT > Content-Type: application/json > Content-Length: 79 > Cache-Control: must-revalidate > [{"id":"04da7996f6503fca300cda889fd6e375","error":"forbidden","reason":"666"}] > POST /test/_bulk_docs HTTP/1.1 > Host: 192.168.1.1:5984 > Transfer-Encoding: chunked > Accept: application/json > User-Agent: CouchDB-Python/0.9dev > Content-Type: application/json > 87 > {"all_or_nothing": true, "docs": [{"_rev": "1-967a00dff5e02add41819138abb3284d", "_id": "04da7996f6503fca300cda889fd6e375", "v": 666}]} > 0 > HTTP/1.1 417 Expectation Failed > Server: CouchDB/1.3.0 (Erlang OTP/R15B) > Date: Tue, 16 Apr 2013 12:38:15 GMT > Content-Type: application/json > Content-Length: 111 > Cache-Control: must-revalidate > [{"id":"04da7996f6503fca300cda889fd6e375","rev":"1-.z\u0000...*.A..8..(M","error":"forbidden","reason":"666"}] > ========================= > From couchdb log (debug) > ================================= > [Tue, 16 Apr 2013 12:38:15 GMT] [debug] [<0.11369.0>] 'POST' /test/_bulk_docs {1,1} from "192.168.1.54" > Headers: [{'Accept',"application/json"}, > {'Content-Type',"application/json"}, > {'Host',"192.168.1.1:5984"}, > {'Transfer-Encoding',"chunked"}, > {'User-Agent',"CouchDB-Python/0.9dev"}] > [Tue, 16 Apr 2013 12:38:15 GMT] [debug] [<0.11369.0>] OAuth Params: [] > [Tue, 16 Apr 2013 12:38:15 GMT] [debug] [<0.109.0>] DDocProc found for DDocKey: {<<"_design/projects">>, > <<"39-4232874e2956d9085f2d7aaf8567c3d9">>} > [Tue, 16 Apr 2013 12:38:15 GMT] [debug] [<0.353.0>] OS Process #Port<0.3439> Input :: ["reset",{"reduce_limit":true,"timeout":5000}] > [Tue, 16 Apr 2013 12:38:15 GMT] [debug] [<0.353.0>] OS Process #Port<0.3439> Output :: true > [Tue, 16 Apr 2013 12:38:15 GMT] [debug] [<0.353.0>] OS Process #Port<0.3439> Input :: ["ddoc","_design/projects",["validate_doc_update"],[{"_id":"04da7996f6503fca300cda889fd6e375","_rev":"1-967a00dff5e02add41819138abb3284d","v":666,"_revisions":{"start":1,"ids":["967a00dff5e02add41819138abb3284d"]}},{"_id":"04da7996f6503fca300cda889fd6e375","_rev":"1-967a00dff5e02add41819138abb3284d","_revisions":{"start":1,"ids":["967a00dff5e02add41819138abb3284d"]}},{"db":"test","name":null,"roles":[]},{}]] > [Tue, 16 Apr 2013 12:38:15 GMT] [debug] [<0.353.0>] OS Process #Port<0.3439> Output :: {"forbidden":"666"} > [Tue, 16 Apr 2013 12:38:15 GMT] [info] [<0.11369.0>] 192.168.1.54 - - POST /test/_bulk_docs 417 > [Tue, 16 Apr 2013 12:38:15 GMT] [debug] [<0.11369.0>] httpd 417 error response: > [{"id":"04da7996f6503fca300cda889fd6e375","rev":"1-<96>z\u0000*
A<81><91>8(M","error":"forbidden","reason":"666"}] > ================================ > As seen, there is something wrong with the way the 'rev' is serialized in the output. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira