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

SDK throws exception on empty FTS errors block

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.7.5
    • 2.7.4
    • FullText
    • None
    • 1

    Description

      It has been seen in certain circumstances that FTS can return the following response to an FTS query as the status block:

      $ curl -sS -u Administrator:password -XPOST -H "Content-Type: application/json" \
      http://10.142.191.102:8094/api/index/test/query \
      -d '{
        "explain": true,
        "fields": [
          "*"
        ],
        "highlight": {},
        "query": {
          "query": "manchester"
        }
      }' | jq '.status'
       
      {
        "total": 6,
        "failed": 0,
        "successful": 6,
        "errors": {}
      }
      

      We can see that there is an "errors" field in the response, but it is empty (which actually means there weren't any errors).
      Now I do think that returning the errors block in the case of no errors is a bug within FTS (covered in MB-33830), I do think that the Java SDK has to be more sensible when handling it.
      Especially as the Java SDK release cadence will produce a 'fix' much sooner than a server-side fix would.

      The issue is that if the SDK receives a response similar to the following it will throw an exception:

      Exception in thread "main" rx.exceptions.CompositeException: 0 exceptions occurred.
      at com.couchbase.client.java.search.result.impl.DefaultAsyncSearchQueryResult.fromJson(DefaultAsyncSearchQueryResult.java:229)
      at com.couchbase.client.java.search.core.SearchQueryExecutor$2.call(SearchQueryExecutor.java:145)
      at com.couchbase.client.java.search.core.SearchQueryExecutor$2.call(SearchQueryExecutor.java:140)
      at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
      at rx.internal.operators.OnSubscribeRedo$2$1.onNext(OnSubscribeRedo.java:244) 
      

      From reviewing the SDK code, this is because we only check if the "errors" field exists and is a JsonObject or JsonArray - https://github.com/couchbase/couchbase-java-client/blob/ccd227cfa63f4571151b09ec5ebbe56b5c4ee43a/src/main/java/com/couchbase/client/java/search/result/impl/DefaultAsyncSearchQueryResult.java#L214-L232.

      Instead, in the JsonObject block we need to be more smart and only set the errors if the object is not empty.

      The result of this issue is that users code will throw exceptions even if the search query worked completely fine.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              graham.pople Graham Pople
              matt.carabine Matt Carabine (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty