[JCBC-150] "Failed to access the view" error when querying a view with reduce Created: 19/Nov/12  Updated: 27/Nov/12  Resolved: 27/Nov/12

Status: Resolved
Project: Couchbase Java Client
Component/s: Core
Affects Version/s: 1.1-dp4
Fix Version/s: None
Security Level: Public

Type: Bug Priority: Blocker
Reporter: Chris Tashjian Assignee: Michael Nitschinger
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attempting to make a call to CouchbaseClient.query(view, query) with a view that has a reduce (even just "_count") results in the following exception when results are returned:

java.lang.RuntimeException: Failed to access the view
at com.couchbase.client.CouchbaseClient.query(CouchbaseClient.java:634)

Worth noting:
- If the query returns no results (ViewResponse.size() returns 0), you do not get the exception...
- If the reduce method is removed from the view, everything works fine. However, using query.setReduce(false) does not work.

Comment by Michael Nitschinger [ 20/Nov/12 ]
Hi Chris,

thanks for the report. I'll investigate and let you know!

Comment by Michael Nitschinger [ 21/Nov/12 ]
Please make sure to use setReduce(true) and .setReduce(false) explicitely on a view with a reduce function right now.

The following code works with setReduce(true) and false, but will throw the exception you mentioned when setReduce is not used at all:

    query = new Query();
    view = client.getView(DESIGN_DOC_W_REDUCE, VIEW_NAME_W_REDUCE);
    reduce = client.query(view, query);
    itr = reduce.iterator();
    while(itr.hasNext()) {
      ViewRow row = itr.next();

Comment by Michael Nitschinger [ 21/Nov/12 ]
After more investigation, this is really a shortcoming and should be handled in this changeset:


It makes sure that reduce = true when nothing is set and the view contains a reduce function. The exception was misleading because it covered a JSON parsing bug underneath.
Comment by Michael Nitschinger [ 27/Nov/12 ]
fixed and pushed to master; will be available in dp5/beta.
Generated at Fri Nov 28 08:46:47 CST 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.