Uploaded image for project: 'C++ Couchbase Client'
  1. C++ Couchbase Client
  2. CXXCBC-173

json streaming lexer doesn't call on_complete if response doesn't contain results array

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.0.0-beta.3
    • 1.0.0-beta.2
    • None
    • None
    • 1
    • SDK22: Lambda + KV Range Scan

    Description

      In the json streaming lexer the on_complete callback is only called at the end of the results array in a response. If the response does not contain a results array the callback is never called. This causes the response data to be empty when decoded which results in a parsing failure being returned.

      It has been observed this is the case with analytics create dataverse queries and possibly other management queries.

      Statement

      CREATE DATAVERSE `default`.`test-scope` IF NOT EXISTS;
      

      HTTP Response

      {
              "requestID": "cfb1376f-c7ca-474b-9aa0-577711ad1de4",
              "clientContextID": "3ad37473-dced-410b-a32b-a81855ce3f28",
              "signature": {
                      "*": "*"
              },
              "plans":{},
              "status": "success",
              "metrics": {
                      "elapsedTime": "263.254299ms",
                      "executionTime": "198.061485ms",
                      "resultCount": 0,
                      "resultSize": 0,
                      "processedObjects": 0
              }
      }
      

      Note there is no "results" key.

      Repro

      TEST_CASE("analytics create dataset")
      {
          test::utils::integration_test_guard integration;
       
          couchbase::operations::analytics_request req{ "CREATE DATAVERSE `default`.`test-scope` IF NOT EXISTS;" };
          std::vector<std::string> rows{};
          req.row_callback = [&rows](std::string&& row) {
              rows.emplace_back(std::move(row));
              return couchbase::utils::json::stream_control::next_row;
          };
       
          auto resp = test::utils::execute(integration.cluster, req);
       
          REQUIRE_FALSE(resp.ctx.ec);
      }
      

      Attachments

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

        Activity

          People

            avsej Sergey Avseyev
            jake.rawsthorne Jake Rawsthorne
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes