Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-1664

viewQuery with ViewOptions.viewOptions().keys(keys) not working (INVALID_ARGS / bad_request)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Blocker
    • 3.0.6
    • 3.0.5
    • Views
    • None
    • Ubuntu 16.04 with Couchbase 6.5.1 CE
    • 1
    • Critical

    Description

       

      When querying an existing view with the 3.0 SDK it always fails when using keys method in the ViewOptions - looks like it's trying to do an HTTP POST with the keys array as the payload instead of a GET and the server, either isn't expecting a POST at all or is expecting it in a different format.

      I keep getting a CouchbaseException with "viewError":"bad_request","viewErrorReason":"Request body must be a JSON object"

       

      JsonArray keys = JsonArray.create();
       
      // adding key to the JsonArray
       
      ViewResult result = couchbaseBucket.viewQuery(
              "design",
              "view",
              ViewOptions.viewOptions()
                      .keys(keys)
                      .scanConsistency(ViewScanConsistency.REQUEST_PLUS)
                      .timeout(Duration.ofSeconds(30))
      );
      

      com.couchbase.client.core.error.CouchbaseException: Unknown view error: ViewError{error='bad_request', reason='Request body must be a JSON object'} {"completed":true,"coreId":"0xbd8a262700000001","httpStatus":400,"idempotent":true,"lastDispatchedFrom":"127.0.0.1:46968","lastDispatchedTo":"127.0.0.1:8092","requestId":9824,"requestType":"ViewRequest","retried":0,"service":{"bucket":"simplehms","designDoc":"design","development":false,"type":"views","viewName":"view"},"status":"INVALID_ARGS","timeoutMs":30000,"timings":{"dispatchMicros":2928,"totalMicros":3528},"viewError":"bad_request","viewErrorReason":"Request body must be a JSON object"}com.couchbase.client.core.error.CouchbaseException: Unknown view error: ViewError{error='bad_request', reason='Request body must be a JSON object'} {"completed":true,"coreId":"0xbd8a262700000001","httpStatus":400,"idempotent":true,"lastDispatchedFrom":"127.0.0.1:46968","lastDispatchedTo":"127.0.0.1:8092","requestId":9824,"requestType":"ViewRequest","retried":0,"service":{"bucket":"simplehms","designDoc":"design","development":false,"type":"views","viewName":"view"},"status":"INVALID_ARGS","timeoutMs":30000,"timings":{"dispatchMicros":2928,"totalMicros":3528},"viewError":"bad_request","viewErrorReason":"Request body must be a JSON object"} at javax.el.BeanELResolver.invoke(BeanELResolver.java:164) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:79) at org.apache.el.parser.AstValue.getValue(AstValue.java:159) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184) at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:96) ... 125 common frames omittedCaused by: com.couchbase.client.core.error.CouchbaseException: Unknown view error: ViewError{error='bad_request', reason='Request body must be a JSON object'} at com.couchbase.client.java.AsyncUtils.block(AsyncUtils.java:51) at com.couchbase.client.java.Bucket.viewQuery(Bucket.java:193) ... 130 common frames omitted Suppressed: java.lang.Exception: The above exception was originally thrown by another thread at the following location. at com.couchbase.client.core.io.netty.view.ViewChunkResponseParser.lambda$error$5(ViewChunkResponseParser.java:88) at java.util.Optional.map(Optional.java:215) at com.couchbase.client.core.io.netty.view.ViewChunkResponseParser.error(ViewChunkResponseParser.java:81) at com.couchbase.client.core.io.netty.chunk.ChunkedMessageHandler.lambda$maybeCompleteResponseWithFailure$1(ChunkedMessageHandler.java:259) at java.util.Optional.orElseGet(Optional.java:267) at com.couchbase.client.core.io.netty.chunk.ChunkedMessageHandler.maybeCompleteResponseWithFailure(ChunkedMessageHandler.java:258) at com.couchbase.client.core.io.netty.chunk.ChunkedMessageHandler.channelRead(ChunkedMessageHandler.java:191) at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at com.couchbase.client.core.deps.io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at com.couchbase.client.core.deps.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at com.couchbase.client.core.deps.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) at com.couchbase.client.core.deps.io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at com.couchbase.client.core.deps.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at com.couchbase.client.core.deps.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at com.couchbase.client.core.deps.io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:792) at com.couchbase.client.core.deps.io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475) at com.couchbase.client.core.deps.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) at com.couchbase.client.core.deps.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at com.couchbase.client.core.deps.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at com.couchbase.client.core.deps.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ... 1 common frames omitted
      

       

      Attachments

        For Gerrit Dashboard: JCBC-1664
        # Subject Branch Project Status CR V

        Activity

          People

            daschl Michael Nitschinger
            prainer Peter Rainer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty