From youngnh at gmail.com Wed Jun 3 16:52:38 2009 From: youngnh at gmail.com (Nate Young) Date: Wed, 3 Jun 2009 11:52:38 -0500 Subject: [clouchdb-devel] create-db via a squid proxy Message-ID: <88494d430906030952g3262e98bne2ce1b40e8de3b47@mail.gmail.com> Hi, I probably wouldn't have even noticed this, as clouchdb has been working great for me, but at work my requests to create a database were blowing up on me: invalid array index 0 for "" (should be nonnegative and <0) ?? [Condition of type SIMPLE-TYPE-ERROR] Restarts: ?0: [RETRY] Retry SLIME interactive evaluation request. ?1: [ABORT] Return to SLIME's top level. ?2: [TERMINATE-THREAD] Terminate this thread (#) Backtrace: ? 0: (SB-IMPL::OPTIMIZED-DATA-VECTOR-REF # #) ? 1: (CLOUCHDB::READ-JSON-NUMBER #) ? 2: (JSON-TO-DOCUMENT ..) ? 3: (CLOUCHDB::DB-REQUEST "test_db/")[:EXTERNAL] ? 4: (CREATE-DB)[:EXTERNAL] ? 5: ((LAMBDA ())) ? 6: (SB-INT:SIMPLE-EVAL-IN-LEXENV (WITH-CONNECTION (:HOST "baseball.fantasy.game-host.org" :PORT "80" :DB-NAME "test_db") (CREATE-DB :DB-NAME "test_db" :IF-EXISTS :RECREATE)) #) ? 7: ((LAMBDA ())) ?--more-- After some digging, I found that I am behind a squid proxy and my HTTP PUT request was being responded to with a 411 error code "Length required".? create-db results in a drakma PUT request, which doesn't contain a "Content-Length" header. I suspect that this is also the case for any other api calls that result in POST or PUT requests without Content-Length headers, I haven't searched that deep. Adding :content-length t key parameter to the http-request call in db-request didn't induce drakma to actually add the header for me. Adding :content "" did, and the request succeeded. --- clouchdb.lisp??? 2009-06-03 11:47:29.000000000 -0500 +++ /home/soafa-user/lisp/clouchdb.lisp??? 2009-06-03 11:47:50.000000000 -0500 @@ -437,7 +437,7 @@ ?and create a new database." ?? (let* ((name (if db-name-p db-name *db-name*)) ???? ?(res (db-request (cat (url-encode name) "/") -????????????????????????? :method :put))) +????????????????????????? :method :put :content ""))) ???? (if (equal "database_already_exists" (document-property :|error| res)) ?????? (ecase if-exists ???? ((:ignore) (list (cons :|ok| t) (cons :|ignored| t))) It's a small change, I attached the diff. Cheers, ? Nate -------------- next part -------------- A non-text attachment was scrubbed... Name: clouchdb.diff Type: application/octet-stream Size: 532 bytes Desc: not available URL: From peter.eddy at gmail.com Wed Jun 3 18:34:32 2009 From: peter.eddy at gmail.com (Peter Eddy) Date: Wed, 3 Jun 2009 14:34:32 -0400 Subject: [clouchdb-devel] create-db via a squid proxy In-Reply-To: <88494d430906030952g3262e98bne2ce1b40e8de3b47@mail.gmail.com> References: <88494d430906030952g3262e98bne2ce1b40e8de3b47@mail.gmail.com> Message-ID: <5aea26870906031134j10b7747eoeb06e40625124126@mail.gmail.com> On Wed, Jun 3, 2009 at 12:52 PM, Nate Young wrote: > Adding :content-length t key parameter to the http-request call in > db-request didn't induce drakma to actually add the header for me. > Adding :content "" did, and the request succeeded. Thanks very much! I'll check in your patch in as soon as possible. - Peter From youngnh at gmail.com Thu Jun 11 14:58:11 2009 From: youngnh at gmail.com (Nate Young) Date: Thu, 11 Jun 2009 09:58:11 -0500 Subject: [clouchdb-devel] INVOKE-VIEW Bug Message-ID: <88494d430906110758m54d165dbk5c4a092f98360347@mail.gmail.com> Hi, I'm running a CouchDB v0.9.0 server, and the following code results in a ((:|error| . "not_found") (:|reason| . "missing")) (create-ps-view "company" (ps-view ("all") (defun map (doc) (with-slots (type) doc (if (eql "customer" type) (emit null doc)))))) (invoke-view "company" "all") I think this is related to the way clouchdb is creating its view id, it should be requesting "_design/company/_view/all" but is instead requesting "_view/company/all". I don't know if this is a version issue or not, but I've attached a patch that makes it work for me. Nate -------------- next part -------------- A non-text attachment was scrubbed... Name: clouchdb.diff Type: application/octet-stream Size: 639 bytes Desc: not available URL: From peter.eddy at gmail.com Thu Jun 11 16:21:27 2009 From: peter.eddy at gmail.com (Peter Eddy) Date: Thu, 11 Jun 2009 12:21:27 -0400 Subject: [clouchdb-devel] INVOKE-VIEW Bug In-Reply-To: <88494d430906110758m54d165dbk5c4a092f98360347@mail.gmail.com> References: <88494d430906110758m54d165dbk5c4a092f98360347@mail.gmail.com> Message-ID: <5aea26870906110921j64cb101fv6f351afc453cab18@mail.gmail.com> On Thu, Jun 11, 2009 at 10:58 AM, Nate Young wrote: > Hi, I'm running a CouchDB v0.9.0 server, and the following code > results in a ((:|error| . "not_found") (:|reason| . "missing")) > I think this is related to the way clouchdb is creating its view id, > it should be requesting "_design/company/_view/all" but is instead > requesting "_view/company/all". ?I don't know if this is a version > issue or not, but I've attached a patch that makes it work for me. Hi Nate, are you running from an ASDF install? If so, there are a number of changes checked in to clouchdb CVS to support changes in couchdb v0.9, you might want to try that. I've been trying to keep the ASDF version current with the semi-release CouchdDb versions, and the CVS clouchdb current with the current CouchDb source. - Peter