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 A1D80D194 for ; Wed, 3 Oct 2012 07:04:11 +0000 (UTC) Received: (qmail 654 invoked by uid 500); 3 Oct 2012 07:04:11 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 357 invoked by uid 500); 3 Oct 2012 07:04:09 -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 287 invoked by uid 99); 3 Oct 2012 07:04:08 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2012 07:04:08 +0000 Date: Wed, 3 Oct 2012 18:04:08 +1100 (NCT) From: "Stephane Alnet (JIRA)" To: dev@couchdb.apache.org Message-ID: <2077911831.158044.1349247848125.JavaMail.jiratomcat@arcas> In-Reply-To: <783413885.465.1305042407500.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (COUCHDB-1155) Etag send by list function does not depend on userCtx 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-1155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13468376#comment-13468376 ] Stephane Alnet commented on COUCHDB-1155: ----------------------------------------- This issue could probably be renamed "why do list functions provide an Etag?". As much as map and reduce functions are required to be idempotent, there's no such requirement for list functions -- they are the only way to do e.g. a query that is time-dependent (using "new Date()" inside the list function) server-side. Unless the CouchDB API is modified to require list functions to be idempotent (same inputs = same outputs), to be able to send a valid Etag back with the response CouchDB would have to compute some hash of the output of the function every time it is eval'ed, since the output might be different every time (even with identical inputs). > Etag send by list function does not depend on userCtx > ----------------------------------------------------- > > Key: COUCHDB-1155 > URL: https://issues.apache.org/jira/browse/COUCHDB-1155 > Project: CouchDB > Issue Type: Bug > Components: HTTP Interface > Affects Versions: 1.0.2 > Reporter: Johannes J. Schmidt > Assignee: Randall Leeds > > List functions should send a different Etag when requested by different users. > The following curl session shows identical Etags for different users. CouchDB must not be in admin party mode. > PROTOCOL=http > DOMAIN="127.0.0.1:5984" > DB=testdb > # admin credentials for db creation > ADMIN=admin:secure > # this user must have an empty roles array > USER=user:secure > curl -XDELETE $PROTOCOL://$ADMIN@$DOMAIN/$DB > curl -XPUT $PROTOCOL://$ADMIN@$DOMAIN/$DB > curl -XPUT $PROTOCOL://$ADMIN@$DOMAIN/$DB/foo -d '{"count":1}' > curl -XPUT $PROTOCOL://$ADMIN@$DOMAIN/$DB/_design/foo -d '{ "views": { "bar": { "map": "function(doc) { emit(doc._id, null); }" } }, "lists": { "bar": "function(head, req) { return req.userCtx.name || \"anonymous\" }" }}' > curl -s $PROTOCOL://$DOMAIN/$DB/_design/foo/_list/bar/bar --head | grep Etag > curl -s $PROTOCOL://$USER@$DOMAIN/$DB/_design/foo/_list/bar/bar --head | grep Etag > #=> Etag: "A1NKHA0935KMCSHFSK94EHZNL" > #=> Etag: "A1NKHA0935KMCSHFSK94EHZNL" > This issue is important for standalone CouchDB applications which use list functions depending on the user context, eg. showing a login button or username. > regards > Johannes > PS: I tried to write a javascript test case but this issue can only be reproduced if the server is not in admin party mode, which the test suite requires. I am not so familar with those tests to temporarily change the admin party. -- 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